|  |  | @ -1,5 +1,6 @@ | 
			
		
	
		
			
				
					|  |  |  | package com.epmet.opendata.service.impl; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.Constant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.NumConstant; | 
			
		
	
	
		
			
				
					|  |  | @ -7,14 +8,22 @@ import com.epmet.commons.tools.exception.RenException; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.ConvertUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.Result; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.constant.IndexCalConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.org.form.GridBaseInfoFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.org.result.CustomerAgencyDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.org.result.CustomerGridDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.feign.DataStatisticalOpenFeignClient; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.opendata.dao.EventreportPingyinDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.opendata.dao.GridInfoPingyinDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.opendata.dao.GridstaffInfoPingyinDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.opendata.dao.GridstaffWorkInfoPingyinDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.opendata.dto.constant.DataWorkerConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.opendata.dto.form.ExractGridInfoPingYinFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.opendata.entity.EventreportPingyinEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.opendata.entity.GridInfoPingyinEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.opendata.entity.GridstaffInfoPingyinEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.opendata.entity.GridstaffWorkInfoPingyinEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.opendata.service.GridInfoPingyinService; | 
			
		
	
		
			
				
					|  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.collections4.CollectionUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.collections4.ListUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.lang3.StringUtils; | 
			
		
	
	
		
			
				
					|  |  | @ -33,11 +42,18 @@ import java.util.List; | 
			
		
	
		
			
				
					|  |  |  |  * @author generator generator@elink-cn.com | 
			
		
	
		
			
				
					|  |  |  |  * @since v1.0.0 2022-07-22 | 
			
		
	
		
			
				
					|  |  |  |  */ | 
			
		
	
		
			
				
					|  |  |  | @Slf4j | 
			
		
	
		
			
				
					|  |  |  | @Service | 
			
		
	
		
			
				
					|  |  |  | public class GridInfoPingyinServiceImpl extends BaseServiceImpl<GridInfoPingyinDao, GridInfoPingyinEntity> implements GridInfoPingyinService { | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private GridstaffInfoPingyinDao gridstaffInfoPingyinDao; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private GridstaffWorkInfoPingyinDao gridstaffWorkInfoPingyinDao; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private EventreportPingyinDao eventreportPingyinDao; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * 抽取customer_agency到grid_info_pingyin表 | 
			
		
	
	
		
			
				
					|  |  | @ -99,9 +115,13 @@ public class GridInfoPingyinServiceImpl extends BaseServiceImpl<GridInfoPingyinD | 
			
		
	
		
			
				
					|  |  |  |             this.insertBatch(gridInfoList); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         } else if (formDTO.getType().contains(DataWorkerConstant.CHANGE)) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             // 修改组织时,先根据code查询,如果有数据,更新
 | 
			
		
	
		
			
				
					|  |  |  |             for (GridInfoPingyinEntity entity : gridInfoList) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                 //网格code变更了 则将旧的code 的数据删除状态设置为Y
 | 
			
		
	
		
			
				
					|  |  |  |                 if (StringUtils.isNotBlank(formDTO.getOldCode()) && !formDTO.getOldCode().equals(entity.getGridCode())){ | 
			
		
	
		
			
				
					|  |  |  |                     baseDao.deleteByCode(formDTO.getOldCode()); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |                 List<GridInfoPingyinEntity> orginList = baseDao.selectByGridCode(entity.getGridCode()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                 if (CollectionUtils.isNotEmpty(orginList)) { | 
			
		
	
	
		
			
				
					|  |  | @ -138,7 +158,7 @@ public class GridInfoPingyinServiceImpl extends BaseServiceImpl<GridInfoPingyinD | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public void exractGrid(ExractGridInfoPingYinFormDTO formDTO) { | 
			
		
	
		
			
				
					|  |  |  |         // 1.查询网格基础信息
 | 
			
		
	
		
			
				
					|  |  |  |         com.epmet.dto.org.form.GridBaseInfoFormDTO formDTO1 = ConvertUtils.sourceToTarget(formDTO, com.epmet.dto.org.form.GridBaseInfoFormDTO.class); | 
			
		
	
		
			
				
					|  |  |  |         GridBaseInfoFormDTO formDTO1 = ConvertUtils.sourceToTarget(formDTO, GridBaseInfoFormDTO.class); | 
			
		
	
		
			
				
					|  |  |  |         if (StringUtils.isBlank(formDTO.getType())||DataWorkerConstant.ALL.equals(formDTO.getType())) { | 
			
		
	
		
			
				
					|  |  |  |             formDTO1.setDelFlag("0"); | 
			
		
	
		
			
				
					|  |  |  |         } else if (formDTO.getType().contains(DataWorkerConstant.CREATE)) { | 
			
		
	
	
		
			
				
					|  |  | @ -150,6 +170,7 @@ public class GridInfoPingyinServiceImpl extends BaseServiceImpl<GridInfoPingyinD | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         Result<List<CustomerGridDTO>> result = dataStatisticalOpenFeignClient.getGridBaseInfo(formDTO1); | 
			
		
	
		
			
				
					|  |  |  |         if (!result.success()) { | 
			
		
	
		
			
				
					|  |  |  |             log.warn("根据网格Id 没有找到网格 等待再次调用"); | 
			
		
	
		
			
				
					|  |  |  |             throw new RenException(result.getInternalMsg()); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         if (null == result.getData() || result.getData().size() < NumConstant.ONE) { | 
			
		
	
	
		
			
				
					|  |  | @ -195,7 +216,9 @@ public class GridInfoPingyinServiceImpl extends BaseServiceImpl<GridInfoPingyinD | 
			
		
	
		
			
				
					|  |  |  |         } else if (formDTO.getType().contains(DataWorkerConstant.CHANGE)) { | 
			
		
	
		
			
				
					|  |  |  |             // 修改组织时,先根据code查询,如果有数据,更新
 | 
			
		
	
		
			
				
					|  |  |  |             for (GridInfoPingyinEntity entity : gridInfoList) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                 //code 变更了
 | 
			
		
	
		
			
				
					|  |  |  |                 gridCodeChanged(formDTO, entity); | 
			
		
	
		
			
				
					|  |  |  |                 //根据修改后的网格code 获取网格信息
 | 
			
		
	
		
			
				
					|  |  |  |                 List<GridInfoPingyinEntity> orginList = baseDao.selectByGridCode(entity.getGridCode()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                 if (CollectionUtils.isNotEmpty(orginList)) { | 
			
		
	
	
		
			
				
					|  |  | @ -224,5 +247,51 @@ public class GridInfoPingyinServiceImpl extends BaseServiceImpl<GridInfoPingyinD | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * desc:判断是否需要网格Code 如果修改了则 同步修改其他的相关业务数据。 | 
			
		
	
		
			
				
					|  |  |  |      * @param formDTO | 
			
		
	
		
			
				
					|  |  |  |      * @param entity | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     private void gridCodeChanged(ExractGridInfoPingYinFormDTO formDTO, GridInfoPingyinEntity entity) { | 
			
		
	
		
			
				
					|  |  |  |         if (StringUtils.isNotBlank(formDTO.getOldCode()) && !formDTO.getOldCode().equals(entity.getGridCode())){ | 
			
		
	
		
			
				
					|  |  |  |             GridInfoPingyinEntity gridInfoEntity = new GridInfoPingyinEntity(); | 
			
		
	
		
			
				
					|  |  |  |             gridInfoEntity.setGridCode(entity.getGridCode()); | 
			
		
	
		
			
				
					|  |  |  |             gridInfoEntity.setUpdateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |             LambdaUpdateWrapper<GridInfoPingyinEntity> updateWrapper = new LambdaUpdateWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |             updateWrapper.eq(GridInfoPingyinEntity::getGridCode,formDTO.getOldCode()); | 
			
		
	
		
			
				
					|  |  |  |             int update = baseDao.update(gridInfoEntity, updateWrapper); | 
			
		
	
		
			
				
					|  |  |  |             log.info("code changed gridinfo effect row:{}",update); | 
			
		
	
		
			
				
					|  |  |  |             //更新完 网格code 去更新其他的业务【工作人员、例行工作、事件】数据对应的code
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             GridstaffInfoPingyinEntity staffInfo = new GridstaffInfoPingyinEntity(); | 
			
		
	
		
			
				
					|  |  |  |             staffInfo.setGridCode(entity.getGridCode()); | 
			
		
	
		
			
				
					|  |  |  |             staffInfo.setUpdateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             LambdaUpdateWrapper<GridstaffInfoPingyinEntity> staffInfoWrapper = new LambdaUpdateWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |             staffInfoWrapper.eq(GridstaffInfoPingyinEntity::getGridCode,formDTO.getOldCode()); | 
			
		
	
		
			
				
					|  |  |  |             update = gridstaffInfoPingyinDao.update(staffInfo, staffInfoWrapper); | 
			
		
	
		
			
				
					|  |  |  |             log.info("code changed gridStaffInfo effect row:{}",update); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             GridstaffWorkInfoPingyinEntity workInfo = new GridstaffWorkInfoPingyinEntity(); | 
			
		
	
		
			
				
					|  |  |  |             workInfo.setGridCode(entity.getGridCode()); | 
			
		
	
		
			
				
					|  |  |  |             workInfo.setUpdateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             LambdaUpdateWrapper<GridstaffWorkInfoPingyinEntity> workInfoWrapper = new LambdaUpdateWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |             workInfoWrapper.eq(GridstaffWorkInfoPingyinEntity::getGridCode,formDTO.getOldCode()); | 
			
		
	
		
			
				
					|  |  |  |             update = gridstaffWorkInfoPingyinDao.update(workInfo, workInfoWrapper); | 
			
		
	
		
			
				
					|  |  |  |             log.info("code changed staffWorkInfo effect row:{}",update); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             EventreportPingyinEntity eventEntity = new EventreportPingyinEntity(); | 
			
		
	
		
			
				
					|  |  |  |             eventEntity.setGridCode(entity.getGridCode()); | 
			
		
	
		
			
				
					|  |  |  |             eventEntity.setUpdateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             LambdaUpdateWrapper<EventreportPingyinEntity> eventWrapper = new LambdaUpdateWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |             eventWrapper.eq(EventreportPingyinEntity::getGridCode,formDTO.getOldCode()); | 
			
		
	
		
			
				
					|  |  |  |             update = eventreportPingyinDao.update(eventEntity, eventWrapper); | 
			
		
	
		
			
				
					|  |  |  |             log.info("code changed eventreport effect row:{}",update); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
	
		
			
				
					|  |  | 
 |