|  | @ -22,18 +22,31 @@ 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.ScreenCustomerGridDao; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dao.evaluationindex.screen.ScreenProjectGridDailyDao; |  |  | import com.epmet.dao.evaluationindex.screen.ScreenProjectGridDailyDao; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.dto.pingyin.result.EvaluateTotalResultDTO; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.dto.pingyin.result.ProjectTotalResultDTO; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.dto.pingyin.result.ResolvedNumResultDTO; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dto.screen.ScreenProjectGridDailyDTO; |  |  | import com.epmet.dto.screen.ScreenProjectGridDailyDTO; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dto.screencoll.ScreenCollFormDTO; |  |  | import com.epmet.dto.screencoll.ScreenCollFormDTO; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.entity.evaluationindex.screen.ScreenProjectGridDailyEntity; |  |  | import com.epmet.entity.evaluationindex.screen.ScreenProjectGridDailyEntity; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.service.evaluationindex.extract.todata.FactOriginProjectMainDailyService; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.evaluationindex.screen.ScreenProjectGridDailyService; |  |  | import com.epmet.service.evaluationindex.screen.ScreenProjectGridDailyService; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 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.math.BigDecimal; | 
			
		
	
		
		
			
				
					|  |  | import java.util.Arrays; |  |  | import java.util.Arrays; | 
			
		
	
		
		
			
				
					|  |  | import java.util.List; |  |  | import java.util.List; | 
			
		
	
		
		
			
				
					|  |  | import java.util.Map; |  |  | import java.util.Map; | 
			
		
	
	
		
		
			
				
					|  | @ -45,8 +58,15 @@ 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 ScreenProjectGridDailyServiceImpl extends BaseServiceImpl<ScreenProjectGridDailyDao, ScreenProjectGridDailyEntity> implements ScreenProjectGridDailyService { |  |  | public class ScreenProjectGridDailyServiceImpl extends BaseServiceImpl<ScreenProjectGridDailyDao, ScreenProjectGridDailyEntity> implements ScreenProjectGridDailyService { | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private ScreenCustomerGridDao gridDao; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private FactOriginProjectMainDailyService projectMainDailyService; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     @Override |  |  |     @Override | 
			
		
	
		
		
			
				
					|  |  |     public PageData<ScreenProjectGridDailyDTO> page(Map<String, Object> params) { |  |  |     public PageData<ScreenProjectGridDailyDTO> page(Map<String, Object> params) { | 
			
		
	
	
		
		
			
				
					|  | @ -121,4 +141,132 @@ public class ScreenProjectGridDailyServiceImpl extends BaseServiceImpl<ScreenPro | 
			
		
	
		
		
			
				
					|  |  |         baseDao.insertBatch(data.getDataList(),customerId,"APP_USER",data.getDateId()); |  |  |         baseDao.insertBatch(data.getDataList(),customerId,"APP_USER",data.getDateId()); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @Description  数据抽取【网格-日】 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @Param | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @author zxc | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @date 2021/1/28 下午3:05 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Override | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     public void extractionProjectGridDaily(String customerId, String dateId) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         // 查询客户下所有网格
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<ScreenProjectGridDailyDTO> gridInfos = gridDao.selectGridInfoByCustomerId(customerId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (CollectionUtils.isEmpty(gridInfos)){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             throw new RenException(String.format(PingYinConstants.GRID_INFO_IS_ZERO,customerId)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         // 查询 项目总数
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<ProjectTotalResultDTO> projectTotal = projectMainDailyService.selectProjectTotal(customerId, dateId, null); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         // 查询 项目解决数
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<ResolvedNumResultDTO> resolvedNum = projectMainDailyService.selectResolvedNum(customerId, dateId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //查询 参与满意度评价的总次数
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         String[] activeCodesAll = {PingYinConstants.EVALUATE_BAD,PingYinConstants.EVALUATE_GOOD,PingYinConstants.EVALUATE_PERFECT}; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<EvaluateTotalResultDTO> evaluateTotal = projectMainDailyService.selectEvaluateCount(customerId, dateId, getActiveCode(activeCodesAll)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //查询 满意+非常满意的总次数
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         String[] activeCodesGood = {PingYinConstants.EVALUATE_GOOD,PingYinConstants.EVALUATE_PERFECT}; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<EvaluateTotalResultDTO> evaluateGood = projectMainDailyService.selectEvaluateCount(customerId, dateId, getActiveCode(activeCodesGood)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         gridInfos.forEach(g -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             g.setDateId(dateId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             // 项目总数赋值
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             if (!CollectionUtils.isEmpty(projectTotal)){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 projectTotal.forEach(pt -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     if (g.getGridId().equals(pt.getGridId())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         g.setProjectTotal(pt.getProjectTotal()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             // 项目解决数赋值
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             if (!CollectionUtils.isEmpty(resolvedNum)){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 resolvedNum.forEach(rn -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     if (g.getGridId().equals(rn.getGridId())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         g.setResolvedNum(rn.getResolvedNum()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             // 解决率
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             g.setResolvedRatio(getRatio(g.getResolvedNum(),g.getProjectTotal())); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             // 参与满意度评价的总次数 赋值
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             if (!CollectionUtils.isEmpty(evaluateTotal)){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 evaluateTotal.forEach(et -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     if (g.getGridId().equals(et.getOrgId())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         g.setEvaluateTotal(et.getEvaluateCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             // 满意+非常满意的总次数 赋值
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             if (!CollectionUtils.isEmpty(evaluateGood)){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 evaluateGood.forEach(eg -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     if (g.getGridId().equals(eg.getOrgId())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         g.setGoodTotal(eg.getEvaluateCount()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             // 不满意总次数
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             g.setBadTotal(g.getEvaluateTotal()==NumConstant.ZERO ? NumConstant.ZERO : g.getEvaluateTotal() - g.getGoodTotal()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             // 满意率
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             g.setGoodRatio(getRatio(g.getGoodTotal(),g.getEvaluateTotal())); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             // 不满意率
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             g.setBadRatio(getRatio(g.getBadTotal(),g.getEvaluateTotal())); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         log.info(gridInfos.toString()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         delScreenProjectGridDaily(customerId, dateId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         insertScreenProjectGridDaily(gridInfos); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @Description  activeCode处理 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @Param actCode | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @author zxc | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @date 2021/1/29 上午9:33 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     public List<String> getActiveCode(String[] actCode){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<String> activeCodes = Arrays.asList(actCode); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         return activeCodes; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @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; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @Description  新增 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @Param list | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @author zxc | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @date 2021/2/1 上午10:24 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     public void insertScreenProjectGridDaily(List<ScreenProjectGridDailyDTO> list){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<List<ScreenProjectGridDailyDTO>> partition = ListUtils.partition(list, NumConstant.ONE_HUNDRED); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         partition.forEach(p -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             baseDao.insertScreenProjectGridDaily(p); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @Description  删除 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @Param customerId | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @Param dateId | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @author zxc | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @date 2021/2/1 上午10:24 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     public void delScreenProjectGridDaily(String customerId,String dateId){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         Integer flag; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         do { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             flag = baseDao.deleteByDateIdAndCustomerId(customerId,dateId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         }while (flag > NumConstant.ZERO && flag == NumConstant.ONE_THOUSAND); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } |