21 changed files with 1016 additions and 7 deletions
@ -0,0 +1,26 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotEmpty; |
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 区块链:创建项目form dto |
||||
|
*/ |
||||
|
@Data |
||||
|
public class BlockChainCreateProjectFormDTO { |
||||
|
|
||||
|
@NotNull(message = "项目信息不能为空") |
||||
|
private BlockChainProjectFormDTO project; |
||||
|
|
||||
|
@NotNull(message = "处理进展信息不能为空") |
||||
|
private BlockChainProjectProcessFormDTO process; |
||||
|
|
||||
|
@NotNull(message = "指派的人员列表信息不能为空") |
||||
|
@NotEmpty(message = "指派的人员列表信息不能为空") |
||||
|
private List<BlockChainProjectProcessAssignedStaffFormDTO> assignedStaffs; |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,21 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 区块链:项目处理进展信息 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class BlockChainProcessProjectFormDTO { |
||||
|
|
||||
|
@NotNull(message = "处理进展信息不能为空") |
||||
|
private BlockChainProjectProcessFormDTO process; |
||||
|
|
||||
|
private List<BlockChainProjectProcessAssignedStaffFormDTO> assignedStaffs; |
||||
|
|
||||
|
// 处理人信息更新
|
||||
|
private BlockChainProjectProcessAssignedStaffFormDTO handledStaff; |
||||
|
} |
@ -0,0 +1,63 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 区块链项目信息formdto |
||||
|
*/ |
||||
|
@Data |
||||
|
public class BlockChainProjectFormDTO { |
||||
|
@NotBlank(message = "项目ID必填") |
||||
|
private String projectId; |
||||
|
|
||||
|
@NotBlank(message = "客户ID必填") |
||||
|
private String customerId; |
||||
|
|
||||
|
// 客户名称
|
||||
|
private String customerName; |
||||
|
|
||||
|
@NotBlank(message = "标题必填") |
||||
|
private String title; |
||||
|
|
||||
|
@NotBlank(message = "组织ID必填") |
||||
|
private String agencyId; |
||||
|
|
||||
|
// 组织名称
|
||||
|
private String agencyName; |
||||
|
|
||||
|
@NotBlank(message = "项目来源必填") |
||||
|
private String origin; |
||||
|
|
||||
|
@NotBlank(message = "项目来源ID必填") |
||||
|
private String originId; |
||||
|
|
||||
|
@NotBlank(message = "项目状态必填") |
||||
|
private String status; |
||||
|
|
||||
|
@NotBlank(message = "关闭状态必填") |
||||
|
private String closeStatus; |
||||
|
|
||||
|
@NotBlank(message = "组织ID PATH必填") |
||||
|
private String orgIdPath; |
||||
|
|
||||
|
@NotBlank(message = "定位必填") |
||||
|
private String locateAddress; |
||||
|
|
||||
|
@NotBlank(message = "经度必填") |
||||
|
private String locateLongitude; |
||||
|
|
||||
|
@NotBlank(message = "维度必填") |
||||
|
private String locateDimension; |
||||
|
|
||||
|
@NotBlank(message = "创建时间必填") |
||||
|
private Date createdTime; |
||||
|
|
||||
|
@NotBlank(message = "创建者ID必填") |
||||
|
private String createdBy; |
||||
|
|
||||
|
// 创建者名字
|
||||
|
private String createrName; |
||||
|
} |
@ -0,0 +1,64 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 区块链:指派的项目处理人员 form dto |
||||
|
*/ |
||||
|
@Data |
||||
|
public class BlockChainProjectProcessAssignedStaffFormDTO { |
||||
|
@NotBlank(message = "ID必填") |
||||
|
private String id; |
||||
|
|
||||
|
@NotBlank(message = "进展ID必填") |
||||
|
private String processId; |
||||
|
|
||||
|
@NotBlank(message = "项目ID必填") |
||||
|
private String projectId; |
||||
|
|
||||
|
@NotBlank(message = "客户ID必填") |
||||
|
private String customerId; |
||||
|
|
||||
|
@NotBlank(message = "组织ID必填") |
||||
|
private String orgId; |
||||
|
|
||||
|
//组织名称
|
||||
|
private String orgName; |
||||
|
|
||||
|
@NotBlank(message = "部门ID必填") |
||||
|
private String departmentId; |
||||
|
|
||||
|
@NotBlank(message = "网格ID必填") |
||||
|
private String gridId; |
||||
|
|
||||
|
// 网格名称
|
||||
|
private String gridName; |
||||
|
|
||||
|
@NotBlank(message = "组织ID PATH必填") |
||||
|
private String orgIdPath; |
||||
|
|
||||
|
@NotBlank(message = "人员ID必填") |
||||
|
private String staffId; |
||||
|
|
||||
|
// 指派的用户名字
|
||||
|
private String staffName; |
||||
|
|
||||
|
@NotBlank(message = "部门名称必填") |
||||
|
private String departmentName; |
||||
|
|
||||
|
@NotBlank(message = "是否处理必填") |
||||
|
private String isHandle; |
||||
|
|
||||
|
@NotBlank(message = "创建者ID必填") |
||||
|
private String createdBy; |
||||
|
|
||||
|
@NotBlank(message = "创建时间必填") |
||||
|
private Date createdTime; |
||||
|
|
||||
|
// 创建者名字
|
||||
|
private String createrName; |
||||
|
|
||||
|
} |
@ -0,0 +1,85 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
import javax.validation.constraints.NotNull; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 区块链:项目处理form dto |
||||
|
*/ |
||||
|
@Data |
||||
|
public class BlockChainProjectProcessFormDTO { |
||||
|
@NotBlank(message = "处理ID必填") |
||||
|
private String processId; |
||||
|
|
||||
|
@NotBlank(message = "项目ID必填") |
||||
|
private String projectId; |
||||
|
|
||||
|
@NotBlank(message = "客户ID必填") |
||||
|
private String customerId; |
||||
|
|
||||
|
@NotBlank(message = "部门名称必填") |
||||
|
private String departmentName; |
||||
|
|
||||
|
@NotBlank(message = "组织ID必填") |
||||
|
private String agencyId; |
||||
|
|
||||
|
// 组织的ID
|
||||
|
private String agencyName; |
||||
|
|
||||
|
@NotBlank(message = "部门ID必填") |
||||
|
private String departmentId; |
||||
|
|
||||
|
@NotBlank(message = "网格ID必填") |
||||
|
private String gridId; |
||||
|
|
||||
|
// 网格的名称
|
||||
|
private String gridName; |
||||
|
|
||||
|
@NotBlank(message = "组织ID PATH必填") |
||||
|
private String orgIdPath; |
||||
|
|
||||
|
@NotBlank(message = "处理人员ID必填") |
||||
|
private String staffId; |
||||
|
|
||||
|
// 工作人员名字
|
||||
|
private String staffName; |
||||
|
|
||||
|
@NotBlank(message = "操作类型必填") |
||||
|
private String operation; |
||||
|
|
||||
|
@NotBlank(message = "操作名称必填") |
||||
|
private String operationName; |
||||
|
|
||||
|
@NotBlank(message = "公开答复必填") |
||||
|
private String publicReply; |
||||
|
|
||||
|
@NotBlank(message = "内部备注必填必填") |
||||
|
private String internalRemark; |
||||
|
|
||||
|
@NotNull(message = "结束时间必填") |
||||
|
private Date endTime; |
||||
|
|
||||
|
@NotNull(message = "是否发送到外部系统必填") |
||||
|
private Integer isSend; |
||||
|
|
||||
|
@NotNull(message = "耗费天数必填") |
||||
|
private String costWorkDays; |
||||
|
|
||||
|
@NotBlank(message = "创建者ID必填") |
||||
|
private String createdBy; |
||||
|
|
||||
|
// 创建者名字
|
||||
|
private String createrName; |
||||
|
|
||||
|
@NotNull(message = "创建时间必填") |
||||
|
private Date createdTime; |
||||
|
|
||||
|
} |
@ -0,0 +1,47 @@ |
|||||
|
package com.epmet.controller; |
||||
|
|
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
||||
|
import com.epmet.dto.form.BlockChainCreateProjectFormDTO; |
||||
|
import com.epmet.dto.form.BlockChainProcessProjectFormDTO; |
||||
|
import com.epmet.service.BlockChainProjectService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
/** |
||||
|
* 区块链project相关controller |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("/blockchain/project") |
||||
|
public class BlockChainProjectController { |
||||
|
|
||||
|
@Autowired |
||||
|
private BlockChainProjectService blockChainProjectService; |
||||
|
|
||||
|
/** |
||||
|
* 立项 |
||||
|
* @param input |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("create") |
||||
|
public Result blockChainCreateProject(@RequestBody BlockChainCreateProjectFormDTO input) { |
||||
|
ValidatorUtils.validateEntity(input); |
||||
|
blockChainProjectService.blockChainCreateProject(input); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 处理进展 |
||||
|
* @param input |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("process") |
||||
|
public Result blockChainProcessProject(@RequestBody BlockChainProcessProjectFormDTO input) { |
||||
|
ValidatorUtils.validateEntity(input); |
||||
|
blockChainProjectService.blockChainProcessProject(input); |
||||
|
return new Result(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,98 @@ |
|||||
|
package com.epmet.mq.producer; |
||||
|
|
||||
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
||||
|
import com.epmet.mq.properties.RocketMQProperties; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.rocketmq.acl.common.AclClientRPCHook; |
||||
|
import org.apache.rocketmq.acl.common.SessionCredentials; |
||||
|
import org.apache.rocketmq.client.exception.MQClientException; |
||||
|
import org.apache.rocketmq.client.producer.DefaultMQProducer; |
||||
|
import org.apache.rocketmq.client.producer.SendResult; |
||||
|
import org.apache.rocketmq.client.producer.SendStatus; |
||||
|
import org.apache.rocketmq.common.message.Message; |
||||
|
import org.apache.rocketmq.remoting.common.RemotingHelper; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import javax.annotation.PostConstruct; |
||||
|
import javax.annotation.PreDestroy; |
||||
|
|
||||
|
/** |
||||
|
* @Description 描述 |
||||
|
* @Author wangxianzhang |
||||
|
* @Date 2021/11/26 12:33 下午 |
||||
|
* @Version 1.0 |
||||
|
*/ |
||||
|
@Component |
||||
|
@Slf4j |
||||
|
public class BlockChainProducer { |
||||
|
|
||||
|
/** |
||||
|
* topic |
||||
|
*/ |
||||
|
public static final String TOPIC_PROJECT = "project"; |
||||
|
public static final String TOPIC_AUTH = "auth"; |
||||
|
|
||||
|
/** |
||||
|
* tag |
||||
|
*/ |
||||
|
public static final String TAG_SEND_PROJECT = "send_project"; |
||||
|
// 发送处理进展
|
||||
|
public static final String TAG_SEND_PROCESS = "send_process"; |
||||
|
// 发送流转过程中被指派的人员
|
||||
|
public static final String TAG_SEND_ASSIGNED_STAFFS = "send_assigned_staffs"; |
||||
|
// 发送处理完成的人员
|
||||
|
public static final String TAG_SEND_HANDLED_STAFF = "send_handled_staff"; |
||||
|
|
||||
|
/** |
||||
|
* 组 |
||||
|
*/ |
||||
|
public static final String GROUP_EPMET_CLOUD_PROJECT_SENDER = "epmet_cloud_project_sender"; |
||||
|
|
||||
|
private DefaultMQProducer producer; |
||||
|
|
||||
|
@Autowired |
||||
|
private RocketMQProperties rocketMQProperties; |
||||
|
|
||||
|
@PostConstruct |
||||
|
private void postConstruct() { |
||||
|
try { |
||||
|
producer = new DefaultMQProducer(GROUP_EPMET_CLOUD_PROJECT_SENDER, |
||||
|
new AclClientRPCHook(new SessionCredentials(rocketMQProperties.getBlockChain().getAccessKey(), rocketMQProperties.getBlockChain().getSecretKey()))); |
||||
|
producer.setNamesrvAddr(rocketMQProperties.getBlockChain().getNameServer()); |
||||
|
producer.start(); |
||||
|
} catch (MQClientException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 销毁producer |
||||
|
*/ |
||||
|
@PreDestroy |
||||
|
private void preDestroy() { |
||||
|
producer.shutdown(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 发送消息 |
||||
|
* |
||||
|
* @param topic |
||||
|
* @param tag |
||||
|
*/ |
||||
|
public void sendMsg(String topic, String tag, String content) { |
||||
|
try { |
||||
|
Message msg = new Message(topic, tag, content.getBytes(RemotingHelper.DEFAULT_CHARSET)); |
||||
|
SendResult sendResult = producer.send(msg); |
||||
|
if (SendStatus.SEND_OK == sendResult.getSendStatus() |
||||
|
|| SendStatus.SLAVE_NOT_AVAILABLE == sendResult.getSendStatus()) { |
||||
|
log.info("消息发送区块链MQ成功, topic:{}, tag:{}, content:{}", topic, tag, content); |
||||
|
} else { |
||||
|
log.error("消息发送区块链MQ失败, topic:{}, tag:{}, content:{}, status: {}", topic, tag, content, sendResult.getSendStatus()); |
||||
|
} |
||||
|
} catch (Exception e) { |
||||
|
log.error("消息发送区块链MQ出错, topic:{}, tag:{}, content:{}, 错误信息:{]", topic, tag, content, ExceptionUtils.getErrorStackTrace(e)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
package com.epmet.mq.properties; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
|
||||
|
/** |
||||
|
* @Description 描述 |
||||
|
* @Author wangxianzhang |
||||
|
* @Date 2021/11/26 10:03 上午 |
||||
|
* @Version 1.0 |
||||
|
*/ |
||||
|
@ConfigurationProperties(prefix = "rocketmq") |
||||
|
@Data |
||||
|
public class RocketMQProperties { |
||||
|
|
||||
|
// 这里必须new出对象来才能成功封装
|
||||
|
private EpmetCloudInnerProperties epmetCloudInner = new EpmetCloudInnerProperties(); |
||||
|
private BlockChainProperties blockChain = new BlockChainProperties(); |
||||
|
|
||||
|
@Data |
||||
|
public class EpmetCloudInnerProperties { |
||||
|
private Boolean enable; |
||||
|
private String nameServer; |
||||
|
} |
||||
|
|
||||
|
@Data |
||||
|
public class BlockChainProperties { |
||||
|
private Boolean enable; |
||||
|
private String nameServer; |
||||
|
private String accessKey; |
||||
|
private String secretKey; |
||||
|
} |
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
package com.epmet.service; |
||||
|
|
||||
|
import com.epmet.dto.form.BlockChainCreateProjectFormDTO; |
||||
|
import com.epmet.dto.form.BlockChainProcessProjectFormDTO; |
||||
|
|
||||
|
/** |
||||
|
* 区块链:项目service |
||||
|
*/ |
||||
|
public interface BlockChainProjectService { |
||||
|
|
||||
|
void blockChainCreateProject(BlockChainCreateProjectFormDTO input); |
||||
|
void blockChainProcessProject(BlockChainProcessProjectFormDTO input); |
||||
|
|
||||
|
} |
@ -0,0 +1,204 @@ |
|||||
|
package com.epmet.service.impl; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
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 |
||||
|
* @Date 2021/11/26 9:59 上午 |
||||
|
* @Version 1.0 |
||||
|
*/ |
||||
|
@Service |
||||
|
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) { |
||||
|
|
||||
|
BlockChainProjectFormDTO project = input.getProject(); |
||||
|
BlockChainProjectProcessFormDTO process = input.getProcess(); |
||||
|
List<BlockChainProjectProcessAssignedStaffFormDTO> assignedStaffs = input.getAssignedStaffs(); |
||||
|
|
||||
|
fill(project, process, assignedStaffs, null); |
||||
|
|
||||
|
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, BlockChainProjectProcessAssignedStaffFormDTO handledStaff) { |
||||
|
|
||||
|
// 一.填充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) { |
||||
|
fillAssignedStaffInfo(assignedStaff); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 4.填充当前处理人信息
|
||||
|
if (handledStaff != null) { |
||||
|
fillAssignedStaffInfo(handledStaff); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 填充被指派人的信息 |
||||
|
* @param assignedStaff |
||||
|
*/ |
||||
|
private void fillAssignedStaffInfo(BlockChainProjectProcessAssignedStaffFormDTO assignedStaff) { |
||||
|
// 组织信息
|
||||
|
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) { |
||||
|
|
||||
|
BlockChainProjectProcessFormDTO process = input.getProcess(); |
||||
|
List<BlockChainProjectProcessAssignedStaffFormDTO> assignedStaffs = input.getAssignedStaffs(); |
||||
|
BlockChainProjectProcessAssignedStaffFormDTO handledStaff = input.getHandledStaff(); |
||||
|
|
||||
|
fill(null, process, assignedStaffs, handledStaff); |
||||
|
|
||||
|
String processString = JSON.toJSONString(process); |
||||
|
blockChainProducer.sendMsg(BlockChainProducer.TOPIC_PROJECT, BlockChainProducer.TAG_SEND_PROCESS, processString); |
||||
|
|
||||
|
if (assignedStaffs != null && assignedStaffs.size() > 0) { |
||||
|
String assignedStaffsString = JSON.toJSONString(assignedStaffs); |
||||
|
blockChainProducer.sendMsg(BlockChainProducer.TOPIC_PROJECT, BlockChainProducer.TAG_SEND_ASSIGNED_STAFFS, assignedStaffsString); |
||||
|
} |
||||
|
|
||||
|
if (handledStaff != null) { |
||||
|
String handledStaffString = JSON.toJSONString(handledStaff); |
||||
|
blockChainProducer.sendMsg(BlockChainProducer.TOPIC_PROJECT, BlockChainProducer.TAG_SEND_HANDLED_STAFF, handledStaffString); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
package com.epmet.service; |
||||
|
|
||||
|
import com.epmet.entity.ProjectEntity; |
||||
|
import com.epmet.entity.ProjectProcessEntity; |
||||
|
import com.epmet.entity.ProjectStaffEntity; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 上链service接口 |
||||
|
*/ |
||||
|
public interface BlockChainUploadService { |
||||
|
|
||||
|
/** |
||||
|
* 数据上链 |
||||
|
* @param processEntity 处理进展entity |
||||
|
* @param assignedStaffEntities 指派给的工作人员entity |
||||
|
*/ |
||||
|
void send2BlockChain(ProjectEntity projectEntity, ProjectProcessEntity processEntity, List<ProjectStaffEntity> assignedStaffEntities, String projectStaffId); |
||||
|
} |
@ -0,0 +1,147 @@ |
|||||
|
package com.epmet.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.epmet.dao.ProjectStaffDao; |
||||
|
import com.epmet.dto.form.*; |
||||
|
import com.epmet.entity.ProjectEntity; |
||||
|
import com.epmet.entity.ProjectProcessEntity; |
||||
|
import com.epmet.entity.ProjectStaffEntity; |
||||
|
import com.epmet.feign.EpmetThirdOpenFeignClient; |
||||
|
import com.epmet.service.BlockChainUploadService; |
||||
|
import org.apache.commons.collections4.CollectionUtils; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* 区块链上链service实现 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class BlockChainUploadServiceImpl implements BlockChainUploadService { |
||||
|
|
||||
|
@Autowired |
||||
|
private EpmetThirdOpenFeignClient thirdOpenFeignClient; |
||||
|
|
||||
|
@Autowired |
||||
|
private ProjectStaffDao projectStaffDao; |
||||
|
|
||||
|
/** |
||||
|
* 数据上链 |
||||
|
* @param processEntity 处理进展entity |
||||
|
* @param assignedStaffEntities 指派给的工作人员entity |
||||
|
*/ |
||||
|
public void send2BlockChain(ProjectEntity projectEntity, ProjectProcessEntity processEntity, List<ProjectStaffEntity> assignedStaffEntities, String projectStaffId) { |
||||
|
|
||||
|
// 1.项目主信息
|
||||
|
BlockChainProjectFormDTO project = null; |
||||
|
|
||||
|
if (projectEntity != null) { |
||||
|
project = new BlockChainProjectFormDTO(); |
||||
|
project.setAgencyId(projectEntity.getAgencyId()); |
||||
|
project.setProjectId(projectEntity.getId()); |
||||
|
project.setCustomerId(projectEntity.getCustomerId()); |
||||
|
project.setCreatedBy(projectEntity.getCreatedBy()); |
||||
|
project.setCreatedTime(projectEntity.getCreatedTime()); |
||||
|
project.setCloseStatus(projectEntity.getClosedStatus()); |
||||
|
project.setLocateAddress(projectEntity.getLocateAddress()); |
||||
|
project.setLocateDimension(projectEntity.getLocateDimension()); |
||||
|
project.setLocateLongitude(projectEntity.getLocateLongitude()); |
||||
|
project.setOrgIdPath(projectEntity.getOrgIdPath()); |
||||
|
project.setOrigin(projectEntity.getOrigin()); |
||||
|
project.setOriginId(projectEntity.getOriginId()); |
||||
|
project.setStatus(projectEntity.getStatus()); |
||||
|
project.setTitle(projectEntity.getTitle()); |
||||
|
} |
||||
|
|
||||
|
// 2.项目处理进展
|
||||
|
BlockChainProjectProcessFormDTO process = new BlockChainProjectProcessFormDTO(); |
||||
|
process.setProcessId(processEntity.getId()); |
||||
|
process.setCreatedBy(processEntity.getCreatedBy()); |
||||
|
process.setCreatedTime(processEntity.getCreatedTime()); |
||||
|
process.setCostWorkDays(processEntity.getCostWorkdays()); |
||||
|
process.setAgencyId(processEntity.getAgencyId()); |
||||
|
process.setCustomerId(processEntity.getCustomerId()); |
||||
|
process.setDepartmentId(processEntity.getDepartmentId()); |
||||
|
process.setDepartmentName(processEntity.getDepartmentName()); |
||||
|
process.setEndTime(processEntity.getEndTime()); |
||||
|
process.setGridId(processEntity.getGridId()); |
||||
|
process.setInternalRemark(processEntity.getInternalRemark()); |
||||
|
process.setIsSend(processEntity.getIsSend()); |
||||
|
process.setOperation(processEntity.getOperation()); |
||||
|
process.setOperationName(processEntity.getOperationName()); |
||||
|
process.setOrgIdPath(processEntity.getOrgIdPath()); |
||||
|
process.setProjectId(processEntity.getProjectId()); |
||||
|
process.setPublicReply(processEntity.getPublicReply()); |
||||
|
process.setStaffId(processEntity.getStaffId()); |
||||
|
|
||||
|
if (assignedStaffEntities == null) { |
||||
|
LambdaQueryWrapper<ProjectStaffEntity> query = new LambdaQueryWrapper<>(); |
||||
|
query.eq(ProjectStaffEntity::getProcessId, process.getProjectId()); |
||||
|
assignedStaffEntities = projectStaffDao.selectList(query); |
||||
|
} |
||||
|
|
||||
|
if (CollectionUtils.isEmpty(assignedStaffEntities)) { |
||||
|
assignedStaffEntities = new ArrayList<>(); |
||||
|
} |
||||
|
|
||||
|
// 3.指派人员列表
|
||||
|
List<BlockChainProjectProcessAssignedStaffFormDTO> assignedStaffs = assignedStaffEntities.stream().map(e -> { |
||||
|
BlockChainProjectProcessAssignedStaffFormDTO assignedStaff = new BlockChainProjectProcessAssignedStaffFormDTO(); |
||||
|
assignedStaff.setStaffId(e.getStaffId()); |
||||
|
assignedStaff.setCreatedBy(e.getCreatedBy()); |
||||
|
assignedStaff.setCustomerId(e.getCustomerId()); |
||||
|
assignedStaff.setCreatedTime(e.getCreatedTime()); |
||||
|
assignedStaff.setProcessId(e.getProcessId()); |
||||
|
assignedStaff.setDepartmentId(e.getDepartmentId()); |
||||
|
assignedStaff.setDepartmentName(e.getDepartmentName()); |
||||
|
assignedStaff.setGridId(e.getGridId()); |
||||
|
assignedStaff.setId(e.getId()); |
||||
|
assignedStaff.setIsHandle(e.getIsHandle()); |
||||
|
assignedStaff.setOrgId(e.getOrgId()); |
||||
|
assignedStaff.setOrgIdPath(e.getOrgIdPath()); |
||||
|
assignedStaff.setProjectId(e.getProjectId()); |
||||
|
return assignedStaff; |
||||
|
}).collect(Collectors.toList()); |
||||
|
|
||||
|
// 4.当前处理人
|
||||
|
BlockChainProjectProcessAssignedStaffFormDTO handledStaff = null; |
||||
|
if (StringUtils.isNotBlank(projectStaffId)) { |
||||
|
ProjectStaffEntity handledStaffEntity = projectStaffDao.selectById(projectStaffId); |
||||
|
|
||||
|
handledStaff = new BlockChainProjectProcessAssignedStaffFormDTO(); |
||||
|
handledStaff.setStaffId(handledStaffEntity.getStaffId()); |
||||
|
handledStaff.setCreatedBy(handledStaffEntity.getCreatedBy()); |
||||
|
handledStaff.setCustomerId(handledStaffEntity.getCustomerId()); |
||||
|
handledStaff.setCreatedTime(handledStaffEntity.getCreatedTime()); |
||||
|
handledStaff.setProcessId(handledStaffEntity.getProcessId()); |
||||
|
handledStaff.setDepartmentId(handledStaffEntity.getDepartmentId()); |
||||
|
handledStaff.setDepartmentName(handledStaffEntity.getDepartmentName()); |
||||
|
handledStaff.setGridId(handledStaffEntity.getGridId()); |
||||
|
handledStaff.setId(handledStaffEntity.getId()); |
||||
|
handledStaff.setIsHandle(handledStaffEntity.getIsHandle()); |
||||
|
handledStaff.setOrgId(handledStaffEntity.getOrgId()); |
||||
|
handledStaff.setOrgIdPath(handledStaffEntity.getOrgIdPath()); |
||||
|
handledStaff.setProjectId(handledStaffEntity.getProjectId()); |
||||
|
} |
||||
|
|
||||
|
if (project == null) { |
||||
|
// 处理
|
||||
|
BlockChainProcessProjectFormDTO processForm = new BlockChainProcessProjectFormDTO(); |
||||
|
processForm.setProcess(process); |
||||
|
processForm.setAssignedStaffs(assignedStaffs); |
||||
|
processForm.setHandledStaff(handledStaff); |
||||
|
thirdOpenFeignClient.blockChainProcessProject(processForm); |
||||
|
} else { |
||||
|
// 立项
|
||||
|
BlockChainCreateProjectFormDTO createForm = new BlockChainCreateProjectFormDTO(); |
||||
|
createForm.setProject(project); |
||||
|
createForm.setProcess(process); |
||||
|
createForm.setAssignedStaffs(assignedStaffs); |
||||
|
thirdOpenFeignClient.blockChainCreateProject(createForm); |
||||
|
} |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue