|  |  | @ -22,18 +22,28 @@ import com.baomidou.mybatisplus.core.metadata.IPage; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.dynamic.datasource.annotation.DataSource; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
			
		
	
		
			
				
					|  |  |  | 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.utils.ConvertUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.constant.DataSourceConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.constant.PingYinConstants; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.evaluationindex.screen.ScreenProjectOrgDailyDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.pingyin.result.ProjectOrgDailyResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.screen.ScreenProjectOrgDailyDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.screencoll.ScreenCollFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.entity.evaluationindex.screen.ScreenProjectOrgDailyEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.evaluationindex.screen.ScreenProjectOrgDailyService; | 
			
		
	
		
			
				
					|  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.collections4.ListUtils; | 
			
		
	
		
			
				
					|  |  |  | 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.math.BigDecimal; | 
			
		
	
		
			
				
					|  |  |  | import java.util.Arrays; | 
			
		
	
		
			
				
					|  |  |  | import java.util.List; | 
			
		
	
		
			
				
					|  |  |  | import java.util.Map; | 
			
		
	
	
		
			
				
					|  |  | @ -45,8 +55,12 @@ import java.util.Map; | 
			
		
	
		
			
				
					|  |  |  |  * @since v1.0.0 2021-01-27 | 
			
		
	
		
			
				
					|  |  |  |  */ | 
			
		
	
		
			
				
					|  |  |  | @Service | 
			
		
	
		
			
				
					|  |  |  | @Slf4j | 
			
		
	
		
			
				
					|  |  |  | @DataSource(DataSourceConstant.EVALUATION_INDEX) | 
			
		
	
		
			
				
					|  |  |  | public class ScreenProjectOrgDailyServiceImpl extends BaseServiceImpl<ScreenProjectOrgDailyDao, ScreenProjectOrgDailyEntity> implements ScreenProjectOrgDailyService { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private ScreenCustomerAgencyDao agencyDao; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public PageData<ScreenProjectOrgDailyDTO> page(Map<String, Object> params) { | 
			
		
	
	
		
			
				
					|  |  | @ -122,4 +136,84 @@ public class ScreenProjectOrgDailyServiceImpl extends BaseServiceImpl<ScreenProj | 
			
		
	
		
			
				
					|  |  |  |         baseDao.insertBatch(data.getDataList(),customerId,"APP_USER",data.getDateId()); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description  数据抽取【机关-日】 | 
			
		
	
		
			
				
					|  |  |  |      * @Param customerId | 
			
		
	
		
			
				
					|  |  |  |      * @Param dateId | 
			
		
	
		
			
				
					|  |  |  |      * @author zxc | 
			
		
	
		
			
				
					|  |  |  |      * @date 2021/2/1 下午1:32 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public void extractionProjectOrgDaily(String customerId, String dateId) { | 
			
		
	
		
			
				
					|  |  |  |         List<ScreenProjectOrgDailyDTO> agencyInfos = agencyDao.selectAgencyByCustomer(customerId); | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(agencyInfos)){ | 
			
		
	
		
			
				
					|  |  |  |             throw new RenException(String.format(PingYinConstants.AGENCY_INFO_IS_ZERO,customerId)); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         List<ProjectOrgDailyResultDTO> projectOrgDaily = baseDao.selectOrgProject(agencyInfos, dateId); | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(projectOrgDaily)){ | 
			
		
	
		
			
				
					|  |  |  |             log.info(String.format(PingYinConstants.SELECT_GRID_INFO_BY_ORG_IS_NULL,customerId)); | 
			
		
	
		
			
				
					|  |  |  |             return; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         projectOrgDaily.forEach(p -> { | 
			
		
	
		
			
				
					|  |  |  |             p.setBadTotal(null == p.getBadTotal() ? NumConstant.ZERO : p.getBadTotal()); | 
			
		
	
		
			
				
					|  |  |  |             p.setEvaluateTotal(null == p.getEvaluateTotal() ? NumConstant.ZERO : p.getEvaluateTotal()); | 
			
		
	
		
			
				
					|  |  |  |             p.setGoodTotal(null == p.getGoodTotal() ? NumConstant.ZERO : p.getGoodTotal()); | 
			
		
	
		
			
				
					|  |  |  |             p.setProjectTotal(null == p.getProjectTotal() ? NumConstant.ZERO : p.getProjectTotal()); | 
			
		
	
		
			
				
					|  |  |  |             p.setResolvedNum(null == p.getResolvedNum() ? NumConstant.ZERO : p.getResolvedNum()); | 
			
		
	
		
			
				
					|  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |         log.info(projectOrgDaily.toString()); | 
			
		
	
		
			
				
					|  |  |  |         agencyInfos.forEach(a -> { | 
			
		
	
		
			
				
					|  |  |  |             a.setDateId(dateId); | 
			
		
	
		
			
				
					|  |  |  |             projectOrgDaily.forEach(p -> { | 
			
		
	
		
			
				
					|  |  |  |                 if (a.getAreaCode().equals(p.getAreaCode())){ | 
			
		
	
		
			
				
					|  |  |  |                     a.setResolvedRatio(getRatio(p.getResolvedNum(),p.getProjectTotal())); | 
			
		
	
		
			
				
					|  |  |  |                     a.setBadRatio(getRatio(p.getBadTotal(),p.getEvaluateTotal())); | 
			
		
	
		
			
				
					|  |  |  |                     a.setGoodRatio(getRatio(p.getGoodTotal(),p.getEvaluateTotal())); | 
			
		
	
		
			
				
					|  |  |  |                     a.setBadTotal(p.getBadTotal()); | 
			
		
	
		
			
				
					|  |  |  |                     a.setEvaluateTotal(p.getEvaluateTotal()); | 
			
		
	
		
			
				
					|  |  |  |                     a.setGoodTotal(p.getGoodTotal()); | 
			
		
	
		
			
				
					|  |  |  |                     a.setProjectTotal(p.getProjectTotal()); | 
			
		
	
		
			
				
					|  |  |  |                     a.setResolvedNum(p.getResolvedNum()); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |             }); | 
			
		
	
		
			
				
					|  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |         log.info(agencyInfos.toString()); | 
			
		
	
		
			
				
					|  |  |  |         del(customerId, dateId); | 
			
		
	
		
			
				
					|  |  |  |         insert(agencyInfos,customerId,dateId); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description | 
			
		
	
		
			
				
					|  |  |  |      * @Param a | 
			
		
	
		
			
				
					|  |  |  |      * @Param b 分母 | 
			
		
	
		
			
				
					|  |  |  |      * @author zxc | 
			
		
	
		
			
				
					|  |  |  |      * @date 2021/1/29 上午10:10 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     public BigDecimal getRatio(Integer a , Integer b){ | 
			
		
	
		
			
				
					|  |  |  |         if (b == NumConstant.ZERO){ | 
			
		
	
		
			
				
					|  |  |  |             return new BigDecimal(NumConstant.ZERO); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         BigDecimal bigDecimalA = new BigDecimal(a); | 
			
		
	
		
			
				
					|  |  |  |         BigDecimal bigDecimalB = new BigDecimal(b); | 
			
		
	
		
			
				
					|  |  |  |         BigDecimal divide = bigDecimalA.divide(bigDecimalB, NumConstant.FOUR, BigDecimal.ROUND_HALF_UP); | 
			
		
	
		
			
				
					|  |  |  |         return divide; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
			
				
					|  |  |  |     public void insert(List<ScreenProjectOrgDailyDTO> agencyInfos,String customerId,String dateId){ | 
			
		
	
		
			
				
					|  |  |  |         if (!CollectionUtils.isEmpty(agencyInfos)){ | 
			
		
	
		
			
				
					|  |  |  |             List<List<ScreenProjectOrgDailyDTO>> partition = ListUtils.partition(agencyInfos, NumConstant.ONE_HUNDRED); | 
			
		
	
		
			
				
					|  |  |  |             partition.forEach(p -> { | 
			
		
	
		
			
				
					|  |  |  |                 baseDao.insertBatch(p,customerId,PingYinConstants.CREATED_BY,dateId); | 
			
		
	
		
			
				
					|  |  |  |             }); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
			
				
					|  |  |  |     public void del(String customerId,String dateId){ | 
			
		
	
		
			
				
					|  |  |  |         Integer flag; | 
			
		
	
		
			
				
					|  |  |  |         do { | 
			
		
	
		
			
				
					|  |  |  |             flag = baseDao.deleteByDateIdAndCustomerId(customerId, dateId); | 
			
		
	
		
			
				
					|  |  |  |         }while (flag > NumConstant.ZERO && flag == NumConstant.ONE_THOUSAND); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | } |