|
@ -1,10 +1,29 @@ |
|
|
package com.epmet.opendata.service.impl; |
|
|
package com.epmet.opendata.service.impl; |
|
|
|
|
|
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
|
|
import com.epmet.dto.form.CustomerGridStaffListFormDTO; |
|
|
|
|
|
import com.epmet.dto.form.GridStaffUploadtFormDTO; |
|
|
|
|
|
import com.epmet.dto.result.CustomerGridStaffListResultDTO; |
|
|
|
|
|
import com.epmet.dto.result.GridStaffUploadResultDTO; |
|
|
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
import com.epmet.opendata.dao.GridstaffInfoPingyinDao; |
|
|
import com.epmet.opendata.dao.GridstaffInfoPingyinDao; |
|
|
|
|
|
import com.epmet.opendata.dto.form.GridStaffInfoFormDTO; |
|
|
import com.epmet.opendata.entity.GridstaffInfoPingyinEntity; |
|
|
import com.epmet.opendata.entity.GridstaffInfoPingyinEntity; |
|
|
import com.epmet.opendata.service.GridstaffInfoPingyinService; |
|
|
import com.epmet.opendata.service.GridstaffInfoPingyinService; |
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 平阴区网格员基础信息 |
|
|
* 平阴区网格员基础信息 |
|
@ -13,6 +32,60 @@ import org.springframework.stereotype.Service; |
|
|
* @since v1.0.0 2022-07-22 |
|
|
* @since v1.0.0 2022-07-22 |
|
|
*/ |
|
|
*/ |
|
|
@Service |
|
|
@Service |
|
|
|
|
|
@Slf4j |
|
|
public class GridstaffInfoPingyinServiceImpl extends BaseServiceImpl<GridstaffInfoPingyinDao, GridstaffInfoPingyinEntity> implements GridstaffInfoPingyinService { |
|
|
public class GridstaffInfoPingyinServiceImpl extends BaseServiceImpl<GridstaffInfoPingyinDao, GridstaffInfoPingyinEntity> implements GridstaffInfoPingyinService { |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void gridStaffInfo(GridStaffInfoFormDTO formDTO) { |
|
|
|
|
|
//1.查询客户网格下工作人员
|
|
|
|
|
|
CustomerGridStaffListFormDTO org = new CustomerGridStaffListFormDTO(); |
|
|
|
|
|
org.setCustomerId(formDTO.getCustomerId()); |
|
|
|
|
|
Result<List<CustomerGridStaffListResultDTO>> orgList = govOrgOpenFeignClient.gridStaff(org); |
|
|
|
|
|
if (!orgList.success()) { |
|
|
|
|
|
throw new RenException("查询客户网格下工作人员列表信息失败:".concat(orgList.toString())); |
|
|
|
|
|
} |
|
|
|
|
|
log.info(String.format("网格员数据同步,查询到网格下工作人员记录共%s条", orgList.getData().size())); |
|
|
|
|
|
|
|
|
|
|
|
//2.查询客户工作人员基础信息
|
|
|
|
|
|
GridStaffUploadtFormDTO user = new GridStaffUploadtFormDTO(); |
|
|
|
|
|
user.setCustomerId(formDTO.getCustomerId()); |
|
|
|
|
|
Result<List<GridStaffUploadResultDTO>> userList = epmetUserOpenFeignClient.customerStaff(user); |
|
|
|
|
|
if (!userList.success()) { |
|
|
|
|
|
throw new RenException("查询客户下工作人员基础信息失败:".concat(userList.toString())); |
|
|
|
|
|
} |
|
|
|
|
|
log.info(String.format("网格员数据同步,查询到客户下工作人员基础信息记录共%s条", userList.getData().size())); |
|
|
|
|
|
Map<String, GridStaffUploadResultDTO> map = userList.getData().stream().collect(Collectors.toMap(GridStaffUploadResultDTO::getGridUserId, m -> m, (k1, k2) -> k1)); |
|
|
|
|
|
|
|
|
|
|
|
//3.拼装数据
|
|
|
|
|
|
List<GridstaffInfoPingyinEntity> entityList = new ArrayList(); |
|
|
|
|
|
if (!CollectionUtils.isEmpty(orgList.getData()) && !CollectionUtils.isEmpty(userList.getData())) { |
|
|
|
|
|
for (CustomerGridStaffListResultDTO gs : orgList.getData()) { |
|
|
|
|
|
if (map.containsKey(gs.getGridUserId())) { |
|
|
|
|
|
GridstaffInfoPingyinEntity entity = ConvertUtils.sourceToTarget(map.get(gs.getGridUserId()), GridstaffInfoPingyinEntity.class); |
|
|
|
|
|
entity.setQxBm("370124"); |
|
|
|
|
|
entity.setQxMc("平阴县"); |
|
|
|
|
|
entity.setGridCode(gs.getGridCode()); |
|
|
|
|
|
entity.setGridName(gs.getGridName()); |
|
|
|
|
|
entityList.add(entity); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//4.删除表中历史数据
|
|
|
|
|
|
baseDao.del(); |
|
|
|
|
|
|
|
|
|
|
|
//5.批量新增数据
|
|
|
|
|
|
log.info(String.format("网格员数据同步,本次共同步%s条记录", entityList.size())); |
|
|
|
|
|
insertBatch(entityList); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |