|
|
@ -1,14 +1,27 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.epmet.dto.form.BlockChainCreateProjectFormDTO; |
|
|
|
import com.epmet.dto.form.BlockChainProcessProjectFormDTO; |
|
|
|
import com.epmet.commons.tools.constant.ServiceConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.feign.ResultDataResolver; |
|
|
|
import com.epmet.dto.CustomerAgencyDTO; |
|
|
|
import com.epmet.dto.CustomerDTO; |
|
|
|
import com.epmet.dto.CustomerGridDTO; |
|
|
|
import com.epmet.dto.CustomerStaffDTO; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
import com.epmet.feign.OperCrmOpenFeignClient; |
|
|
|
import com.epmet.mq.producer.BlockChainProducer; |
|
|
|
import com.epmet.mq.properties.RocketMQProperties; |
|
|
|
import com.epmet.service.BlockChainProjectService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.Optional; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 描述 |
|
|
|
* @Author wangxianzhang |
|
|
@ -16,27 +29,153 @@ import org.springframework.stereotype.Service; |
|
|
|
* @Version 1.0 |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class BlockChainProjectServiceImpl implements BlockChainProjectService { |
|
|
|
public class BlockChainProjectServiceImpl implements BlockChainProjectService, ResultDataResolver { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private BlockChainProducer blockChainProducer; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private OperCrmOpenFeignClient operCrmOpenFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private EpmetUserOpenFeignClient userOpenFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void blockChainCreateProject(BlockChainCreateProjectFormDTO input) { |
|
|
|
|
|
|
|
String projectString = JSON.toJSONString(input.getProject()); |
|
|
|
String processString = JSON.toJSONString(input.getProcess()); |
|
|
|
String assignedStaffsString = JSON.toJSONString(input.getAssignedStaffs()); |
|
|
|
BlockChainProjectFormDTO project = input.getProject(); |
|
|
|
BlockChainProjectProcessFormDTO process = input.getProcess(); |
|
|
|
List<BlockChainProjectProcessAssignedStaffFormDTO> assignedStaffs = input.getAssignedStaffs(); |
|
|
|
|
|
|
|
fill(project, process, assignedStaffs); |
|
|
|
|
|
|
|
String projectString = JSON.toJSONString(project); |
|
|
|
String processString = JSON.toJSONString(process); |
|
|
|
String assignedStaffsString = JSON.toJSONString(assignedStaffs); |
|
|
|
|
|
|
|
blockChainProducer.sendMsg(BlockChainProducer.TOPIC_PROJECT, BlockChainProducer.TAG_SEND_PROJECT, projectString); |
|
|
|
blockChainProducer.sendMsg(BlockChainProducer.TOPIC_PROJECT, BlockChainProducer.TAG_SEND_PROCESS, processString); |
|
|
|
blockChainProducer.sendMsg(BlockChainProducer.TOPIC_PROJECT, BlockChainProducer.TAG_SEND_ASSIGNED_STAFFS, assignedStaffsString); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 填充数据 |
|
|
|
* @param project |
|
|
|
* @param process |
|
|
|
*/ |
|
|
|
private void fill(BlockChainProjectFormDTO project, BlockChainProjectProcessFormDTO process, List<BlockChainProjectProcessAssignedStaffFormDTO> assignedStaffs) { |
|
|
|
|
|
|
|
// 一.填充project信息
|
|
|
|
|
|
|
|
if (project != null) { |
|
|
|
// 客户信息
|
|
|
|
CustomerDTO customerDTO = new CustomerDTO(); |
|
|
|
customerDTO.setId(project.getCustomerId()); |
|
|
|
CustomerDTO customerInfo = getResultDataOrThrowsException(operCrmOpenFeignClient.getCustomerInfo(customerDTO), |
|
|
|
ServiceConstant.EPMET_THIRD_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【项目信息上链】查询客户信息失败"); |
|
|
|
|
|
|
|
// 组织信息
|
|
|
|
CustomerAgencyDTO agencyInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getAgencyById(project.getAgencyId()), |
|
|
|
ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【项目信息上链】查询Agency信息失败"); |
|
|
|
|
|
|
|
// 用户信息
|
|
|
|
CustomerStaffDTO customerStaffDTO = new CustomerStaffDTO(); |
|
|
|
customerStaffDTO.setUserId(project.getCreatedBy()); |
|
|
|
CustomerStaffDTO staffInfo = getResultDataOrThrowsException(userOpenFeignClient.getCustomerStaffInfoByUserId(customerStaffDTO), |
|
|
|
ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【项目信息上链】查询用户信息失败"); |
|
|
|
|
|
|
|
project.setCustomerName(customerInfo.getCustomerName()); |
|
|
|
project.setAgencyName(agencyInfo.getOrganizationName()); |
|
|
|
Optional.of(staffInfo).ifPresent((staff) -> project.setCreaterName(staff.getRealName())); |
|
|
|
} |
|
|
|
|
|
|
|
// 二.填充进展信息
|
|
|
|
|
|
|
|
if (process != null) { |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(process.getAgencyId())) { |
|
|
|
// 组织信息
|
|
|
|
CustomerAgencyDTO processAgencyInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getAgencyById(process.getAgencyId()), |
|
|
|
ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【项目信息上链】查询处理节点Agency信息失败"); |
|
|
|
|
|
|
|
process.setAgencyName(processAgencyInfo.getOrganizationName()); |
|
|
|
} |
|
|
|
|
|
|
|
// 网格信息
|
|
|
|
if (StringUtils.isNotBlank(process.getGridId())) { |
|
|
|
CustomerGridFormDTO processGridFormDTO = new CustomerGridFormDTO(); |
|
|
|
processGridFormDTO.setGridId(process.getGridId()); |
|
|
|
CustomerGridDTO processGridInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getCustomerGridByGridId(processGridFormDTO), |
|
|
|
ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【项目信息上链】查询处理节点网格信息失败"); |
|
|
|
|
|
|
|
Optional.of(processGridInfo).ifPresent((grid) -> process.setGridName(grid.getGridName())); |
|
|
|
} |
|
|
|
|
|
|
|
// 用户信息
|
|
|
|
CustomerStaffDTO processCustomerStaffDTO = new CustomerStaffDTO(); |
|
|
|
processCustomerStaffDTO.setUserId(process.getStaffId()); |
|
|
|
CustomerStaffDTO processStaffInfo = getResultDataOrThrowsException(userOpenFeignClient.getCustomerStaffInfoByUserId(processCustomerStaffDTO), |
|
|
|
ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【项目信息上链】查询处理节点用户信息失败"); |
|
|
|
|
|
|
|
process.setStaffName(processStaffInfo.getRealName()); |
|
|
|
process.setCreatedBy(processStaffInfo.getRealName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 三.填充指派用户信息
|
|
|
|
if (assignedStaffs != null) { |
|
|
|
for (BlockChainProjectProcessAssignedStaffFormDTO assignedStaff : assignedStaffs) { |
|
|
|
// 组织信息
|
|
|
|
if (StringUtils.isNotBlank(assignedStaff.getOrgId())) { |
|
|
|
CustomerAgencyDTO assignedStaffAgencyInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getAgencyById(assignedStaff.getOrgId()), |
|
|
|
ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【项目信息上链】查询指派人员组织信息失败"); |
|
|
|
|
|
|
|
assignedStaff.setOrgName(assignedStaffAgencyInfo.getOrganizationName()); |
|
|
|
} |
|
|
|
|
|
|
|
// 网格信息
|
|
|
|
if (StringUtils.isNotBlank(assignedStaff.getGridId())) { |
|
|
|
CustomerGridFormDTO assignedStaffGridFormDTO = new CustomerGridFormDTO(); |
|
|
|
assignedStaffGridFormDTO.setGridId(assignedStaff.getGridId()); |
|
|
|
CustomerGridDTO assignedStaffProcessGridInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getCustomerGridByGridId(assignedStaffGridFormDTO), |
|
|
|
ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【项目信息上链】查询指派人员网格信息失败"); |
|
|
|
|
|
|
|
Optional.of(assignedStaffProcessGridInfo).ifPresent((gridOfStaff) -> assignedStaff.setGridName(gridOfStaff.getGridName())); |
|
|
|
} |
|
|
|
|
|
|
|
// 指派用户
|
|
|
|
CustomerStaffDTO assignedStaffDTO = new CustomerStaffDTO(); |
|
|
|
assignedStaffDTO.setUserId(assignedStaff.getStaffId()); |
|
|
|
CustomerStaffDTO assignedStaffInfo = getResultDataOrThrowsException(userOpenFeignClient.getCustomerStaffInfoByUserId(assignedStaffDTO), |
|
|
|
ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【项目信息上链】查询指派用户信息失败"); |
|
|
|
|
|
|
|
assignedStaff.setStaffName(assignedStaffInfo.getRealName()); |
|
|
|
|
|
|
|
// 创建者
|
|
|
|
CustomerStaffDTO createStaffDTO = new CustomerStaffDTO(); |
|
|
|
createStaffDTO.setUserId(assignedStaff.getCreatedBy()); |
|
|
|
CustomerStaffDTO createStaffInfo = getResultDataOrThrowsException(userOpenFeignClient.getCustomerStaffInfoByUserId(createStaffDTO), |
|
|
|
ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【项目信息上链】查询指派用户信息失败"); |
|
|
|
|
|
|
|
Optional.of(createStaffInfo).ifPresent((createStaff) -> assignedStaff.setCreaterName(createStaffInfo.getRealName())); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void blockChainProcessProject(BlockChainProcessProjectFormDTO input) { |
|
|
|
String processString = JSON.toJSONString(input.getProcess()); |
|
|
|
String assignedStaffsString = JSON.toJSONString(input.getAssignedStaffs()); |
|
|
|
|
|
|
|
BlockChainProjectProcessFormDTO process = input.getProcess(); |
|
|
|
List<BlockChainProjectProcessAssignedStaffFormDTO> assignedStaffs = input.getAssignedStaffs(); |
|
|
|
|
|
|
|
fill(null, process, assignedStaffs); |
|
|
|
|
|
|
|
String processString = JSON.toJSONString(process); |
|
|
|
String assignedStaffsString = JSON.toJSONString(assignedStaffs); |
|
|
|
|
|
|
|
blockChainProducer.sendMsg(BlockChainProducer.TOPIC_PROJECT, BlockChainProducer.TAG_SEND_PROCESS, processString); |
|
|
|
blockChainProducer.sendMsg(BlockChainProducer.TOPIC_PROJECT, BlockChainProducer.TAG_SEND_ASSIGNED_STAFFS, assignedStaffsString); |
|
|
|