|  | @ -22,17 +22,28 @@ import com.baomidou.mybatisplus.core.metadata.IPage; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.dynamic.datasource.annotation.DataSource; |  |  | import com.epmet.commons.dynamic.datasource.annotation.DataSource; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |  |  | import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.constant.FieldConstant; |  |  | import com.epmet.commons.tools.constant.FieldConstant; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 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.page.PageData; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.utils.ConvertUtils; |  |  | import com.epmet.commons.tools.utils.ConvertUtils; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.constant.DataSourceConstant; |  |  | import com.epmet.constant.DataSourceConstant; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.constant.PingYinConstants; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dao.evaluationindex.screen.ScreenProjectQuantityOrgMonthlyDao; |  |  | import com.epmet.dao.evaluationindex.screen.ScreenProjectQuantityOrgMonthlyDao; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.dto.pingyin.result.ProjectOrgMonthlyResultDTO; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.dto.screen.ScreenProjectOrgDailyDTO; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dto.screen.ScreenProjectQuantityOrgMonthlyDTO; |  |  | import com.epmet.dto.screen.ScreenProjectQuantityOrgMonthlyDTO; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dto.screencoll.ScreenCollFormDTO; |  |  | import com.epmet.dto.screencoll.ScreenCollFormDTO; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.entity.evaluationindex.screen.ScreenProjectQuantityOrgMonthlyEntity; |  |  | import com.epmet.entity.evaluationindex.screen.ScreenProjectQuantityOrgMonthlyEntity; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.evaluationindex.screen.ScreenProjectQuantityOrgMonthlyService; |  |  | import com.epmet.service.evaluationindex.screen.ScreenProjectQuantityOrgMonthlyService; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import org.apache.commons.collections4.ListUtils; | 
			
		
	
		
		
			
				
					|  |  | import org.apache.commons.lang3.StringUtils; |  |  | import org.apache.commons.lang3.StringUtils; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
		
		
			
				
					|  |  | import org.springframework.stereotype.Service; |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
		
			
				
					|  |  | import org.springframework.transaction.annotation.Transactional; |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import org.springframework.util.CollectionUtils; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | import java.util.Arrays; |  |  | import java.util.Arrays; | 
			
		
	
		
		
			
				
					|  |  | import java.util.List; |  |  | import java.util.List; | 
			
		
	
	
		
		
			
				
					|  | @ -45,8 +56,13 @@ import java.util.Map; | 
			
		
	
		
		
			
				
					|  |  |  * @since v1.0.0 2021-01-27 |  |  |  * @since v1.0.0 2021-01-27 | 
			
		
	
		
		
			
				
					|  |  |  */ |  |  |  */ | 
			
		
	
		
		
			
				
					|  |  | @Service |  |  | @Service | 
			
		
	
		
		
			
				
					|  |  |  |  |  | @Slf4j | 
			
		
	
		
		
			
				
					|  |  |  |  |  | @DataSource(DataSourceConstant.EVALUATION_INDEX) | 
			
		
	
		
		
			
				
					|  |  | public class ScreenProjectQuantityOrgMonthlyServiceImpl extends BaseServiceImpl<ScreenProjectQuantityOrgMonthlyDao, ScreenProjectQuantityOrgMonthlyEntity> implements ScreenProjectQuantityOrgMonthlyService { |  |  | public class ScreenProjectQuantityOrgMonthlyServiceImpl extends BaseServiceImpl<ScreenProjectQuantityOrgMonthlyDao, ScreenProjectQuantityOrgMonthlyEntity> implements ScreenProjectQuantityOrgMonthlyService { | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private ScreenCustomerAgencyDao agencyDao; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     @Override |  |  |     @Override | 
			
		
	
		
		
			
				
					|  |  |     public PageData<ScreenProjectQuantityOrgMonthlyDTO> page(Map<String, Object> params) { |  |  |     public PageData<ScreenProjectQuantityOrgMonthlyDTO> page(Map<String, Object> params) { | 
			
		
	
		
		
			
				
					|  |  |         IPage<ScreenProjectQuantityOrgMonthlyEntity> page = baseDao.selectPage( |  |  |         IPage<ScreenProjectQuantityOrgMonthlyEntity> page = baseDao.selectPage( | 
			
		
	
	
		
		
			
				
					|  | @ -120,4 +136,76 @@ public class ScreenProjectQuantityOrgMonthlyServiceImpl extends BaseServiceImpl< | 
			
		
	
		
		
			
				
					|  |  |         baseDao.insertBatch(data.getDataList(),customerId,"APP_USER",data.getMonthId()); |  |  |         baseDao.insertBatch(data.getDataList(),customerId,"APP_USER",data.getMonthId()); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @Description  数据抽取【组织-月】 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @Param customerId | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @Param monthId | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @author zxc | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @date 2021/2/2 上午10:43 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Override | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     public void extractionProjectOrgMonthly(String customerId, String monthId) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<ScreenProjectOrgDailyDTO> screenProjectOrgDailyDTOS = agencyDao.selectAgencyByCustomer(customerId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (CollectionUtils.isEmpty(screenProjectOrgDailyDTOS)){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             throw new RenException(String.format(PingYinConstants.AGENCY_INFO_IS_ZERO,customerId)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<ScreenProjectQuantityOrgMonthlyDTO> agencyInfos = ConvertUtils.sourceToTarget(screenProjectOrgDailyDTOS, ScreenProjectQuantityOrgMonthlyDTO.class); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<ProjectOrgMonthlyResultDTO> projectOrg = baseDao.selectQuantityOrgMonthly(agencyInfos, monthId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (!CollectionUtils.isEmpty(projectOrg)){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             projectOrg.forEach(p -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 p.setClosedIncr(null == p.getClosedIncr() ? NumConstant.ZERO : p.getClosedIncr()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 p.setProjectIncr(null == p.getProjectIncr() ? NumConstant.ZERO : p.getProjectIncr()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<ProjectOrgMonthlyResultDTO> projectGrandOrg = baseDao.selectQuantityGrandOrgMonthly(agencyInfos, monthId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (!CollectionUtils.isEmpty(projectGrandOrg)){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             projectGrandOrg.forEach(p -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 p.setClosedTotal(null == p.getClosedTotal() ? NumConstant.ZERO : p.getClosedTotal()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 p.setProjectTotal(null == p.getProjectTotal() ? NumConstant.ZERO : p.getProjectTotal()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 p.setUnClosedTotal(null == p.getUnClosedTotal() ? NumConstant.ZERO : p.getUnClosedTotal()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         agencyInfos.forEach(a -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             a.setMonthId(monthId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             if (!CollectionUtils.isEmpty(projectOrg)){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 projectOrg.forEach(p -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     if (a.getAreaCode().equals(p.getAreaCode())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         a.setClosedIncr(p.getClosedIncr()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         a.setProjectIncr(p.getProjectIncr()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             if (!CollectionUtils.isEmpty(projectGrandOrg)){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 projectGrandOrg.forEach(p -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     if (a.getAreaCode().equals(p.getAreaCode())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         a.setClosedTotal(p.getClosedTotal()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         a.setProjectTotal(p.getProjectTotal()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         a.setUnClosedTotal(p.getUnClosedTotal()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         log.info(agencyInfos.toString()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         del(customerId, monthId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         insert(agencyInfos,customerId,monthId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     public void del(String customerId,String monthId){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         Integer flag; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         do { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             flag = baseDao.deleteByMonthIdAndCustomerId(customerId, monthId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         }while (flag > NumConstant.ZERO && flag == NumConstant.ONE_THOUSAND); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     public void insert(List<ScreenProjectQuantityOrgMonthlyDTO> agencyInfos,String customerId,String monthId){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (!CollectionUtils.isEmpty(agencyInfos)){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             List<List<ScreenProjectQuantityOrgMonthlyDTO>> partition = ListUtils.partition(agencyInfos, NumConstant.ONE_HUNDRED); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             partition.forEach(p -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 baseDao.insertBatch(p,customerId,PingYinConstants.CREATED_BY,monthId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } |