Merge remote-tracking branch 'origin/feature/REQ-2348' into feature/REQ-2348
This commit is contained in:
commit
4a4892d6a7
@ -6,7 +6,6 @@ import cn.axzo.framework.rocketmq.EventConsumer;
|
|||||||
import cn.axzo.framework.rocketmq.EventHandlerRepository;
|
import cn.axzo.framework.rocketmq.EventHandlerRepository;
|
||||||
import cn.axzo.framework.rocketmq.EventProducer;
|
import cn.axzo.framework.rocketmq.EventProducer;
|
||||||
import cn.axzo.framework.rocketmq.RocketMQEventProducer;
|
import cn.axzo.framework.rocketmq.RocketMQEventProducer;
|
||||||
import cn.axzo.nanopart.server.event.workspace.WorkerJoinWorkspaceHandler;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.rocketmq.common.message.MessageExt;
|
import org.apache.rocketmq.common.message.MessageExt;
|
||||||
@ -36,9 +35,10 @@ public class RocketMQEventConfiguration {
|
|||||||
private String topic;
|
private String topic;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public RocketMQTemplate ser(){
|
public RocketMQTemplate ser() {
|
||||||
return new RocketMQTemplate();
|
return new RocketMQTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
EventProducer eventProducer(RocketMQTemplate rocketMQTemplate) {
|
EventProducer eventProducer(RocketMQTemplate rocketMQTemplate) {
|
||||||
return new RocketMQEventProducer(rocketMQTemplate,
|
return new RocketMQEventProducer(rocketMQTemplate,
|
||||||
@ -177,4 +177,47 @@ public class RocketMQEventConfiguration {
|
|||||||
super.onEvent(message, eventConsumer);
|
super.onEvent(message, eventConsumer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建施工区域
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@RocketMQMessageListener(topic = "topic_construction_area_${spring.profiles.active]",
|
||||||
|
consumerGroup = "GID_construction_area_${spring.application.name}_${spring.profiles.active}",
|
||||||
|
consumeMode = ConsumeMode.ORDERLY,
|
||||||
|
nameServer = "${rocketmq.name-server}")
|
||||||
|
public static class ConstructionAreaListener extends BaseListener implements RocketMQListener<MessageExt> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EventConsumer eventConsumer;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMessage(MessageExt message) {
|
||||||
|
log.info("ConstructionAreaListener onMessage nanopart, message:{}", JSON.toJSONString(message));
|
||||||
|
super.onEvent(message, eventConsumer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传交底
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@RocketMQMessageListener(topic = "topic_disclosure_${spring.profiles.active}",
|
||||||
|
consumerGroup = "GID_disclosure_${spring.application.name}_${spring.profiles.active}",
|
||||||
|
consumeMode = ConsumeMode.ORDERLY,
|
||||||
|
nameServer = "${rocketmq.name-server}"
|
||||||
|
)
|
||||||
|
public static class DisclosureListener extends BaseListener implements RocketMQListener<MessageExt> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EventConsumer eventConsumer;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMessage(MessageExt message) {
|
||||||
|
log.info("DisclosureListener onMessage nanopart, message:{}", JSON.toJSONString(message));
|
||||||
|
super.onEvent(message, eventConsumer);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,4 +40,10 @@ public class GuideTenantProcedureStatusUpdateReq {
|
|||||||
private GuideProcedureStatus status;
|
private GuideProcedureStatus status;
|
||||||
|
|
||||||
private Long updateBy;
|
private Long updateBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 来源:1-用户操作,2-系统监听MQ处理
|
||||||
|
* 该字段仅用于区分系统监听MQ处理,正常使用可不管该字段
|
||||||
|
*/
|
||||||
|
private Integer from;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,70 @@
|
|||||||
|
package cn.axzo.nanopart.server.enums;
|
||||||
|
|
||||||
|
import cn.axzo.basics.common.util.NumberUtil;
|
||||||
|
import cn.axzo.nanopart.server.domain.GuideProcedureTemplate;
|
||||||
|
import cn.axzo.op.api.enums.GuideProcedureTypeEnum;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作步骤模板枚举
|
||||||
|
* <p>
|
||||||
|
* 对应 数据库表 guide_procedure_template,为减少整体枚举值的数量,
|
||||||
|
* 只记录需要进行异步状态更新的操作步骤,前端上报状态变更的操作步骤不进行枚举
|
||||||
|
*
|
||||||
|
* @author chenwenjian
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/8/9 16:38
|
||||||
|
* @see GuideProcedureTemplate
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum GuideProcedureEnum {
|
||||||
|
|
||||||
|
ADD_NODE_USR(2L, GuideProcedureTypeEnum.ENT, "添加人员"),
|
||||||
|
|
||||||
|
CREATE_PROJECT(3L, GuideProcedureTypeEnum.ENT, "创建项目"),
|
||||||
|
|
||||||
|
CREATE_ENGINEERING_ENT(4L, GuideProcedureTypeEnum.ENT, "创建工程"),
|
||||||
|
|
||||||
|
CREATE_ENGINEERING_PROJECT(5L, GuideProcedureTypeEnum.PROJECT, "创建工程"),
|
||||||
|
|
||||||
|
INVITE_TEAM(6L, GuideProcedureTypeEnum.PROJECT, "邀请参建单位&班组"),
|
||||||
|
|
||||||
|
INVITE_PARTICIPANT(7L, GuideProcedureTypeEnum.PROJECT, "邀请从业人员"),
|
||||||
|
|
||||||
|
CREATE_CONSTRUCTION_AREA(8L, GuideProcedureTypeEnum.PROJECT, "创建施工区"),
|
||||||
|
|
||||||
|
DISCLOSURE(10L, GuideProcedureTypeEnum.PROJECT, "上传交底");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对应步骤模板的id
|
||||||
|
*/
|
||||||
|
private final Long code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对应步骤模板的type
|
||||||
|
*/
|
||||||
|
private final GuideProcedureTypeEnum type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对应步骤模板的name
|
||||||
|
*/
|
||||||
|
private final String desc;
|
||||||
|
|
||||||
|
GuideProcedureEnum(Long code, GuideProcedureTypeEnum type, String desc) {
|
||||||
|
this.code = code;
|
||||||
|
this.type = type;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GuideProcedureEnum getByCode(Long code) {
|
||||||
|
if (NumberUtil.isPositiveNumber(code)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (GuideProcedureEnum value : GuideProcedureEnum.values()) {
|
||||||
|
if (value.getCode().equals(code)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
package cn.axzo.nanopart.server.event;
|
||||||
|
|
||||||
|
import cn.axzo.nanopart.server.enums.GuideProcedureEnum;
|
||||||
|
import cn.axzo.nanopart.server.service.GuideTenantProcedureStatusService;
|
||||||
|
import cn.axzo.op.api.enums.GuideProcedureStatus;
|
||||||
|
import cn.axzo.op.api.request.GuideTenantProcedureStatusUpdateReq;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author chenwenjian
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/8/9 16:52
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class AbstractTenantProcedureStatusHandler {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GuideTenantProcedureStatusService guideTenantProcedureService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新步骤状态
|
||||||
|
*
|
||||||
|
* @param workspaceId 租户id
|
||||||
|
* @param procedure 操作步骤id
|
||||||
|
*/
|
||||||
|
protected void updateTenantStatus(Long workspaceId, GuideProcedureEnum procedure) {
|
||||||
|
GuideTenantProcedureStatusUpdateReq updateReq = new GuideTenantProcedureStatusUpdateReq();
|
||||||
|
updateReq.setWorkspaceId(workspaceId);
|
||||||
|
updateReq.setProcedureId(procedure.getCode());
|
||||||
|
updateReq.setStatus(GuideProcedureStatus.FINISHED);
|
||||||
|
updateReq.setFrom(2);
|
||||||
|
log.info("系统监听MQ处理更新操作状态:{}", JSONUtil.toJsonStr(updateReq));
|
||||||
|
guideTenantProcedureService.updateStatus(updateReq);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
package cn.axzo.nanopart.server.event.apollo;
|
||||||
|
|
||||||
|
import cn.axzo.framework.rocketmq.Event;
|
||||||
|
import cn.axzo.framework.rocketmq.EventConsumer;
|
||||||
|
import cn.axzo.framework.rocketmq.EventHandler;
|
||||||
|
import cn.axzo.nanopart.server.enums.GuideProcedureEnum;
|
||||||
|
import cn.axzo.nanopart.server.event.AbstractTenantProcedureStatusHandler;
|
||||||
|
import cn.axzo.nanopart.server.event.enums.MQEventEnum;
|
||||||
|
import cn.axzo.nanopart.server.event.payload.ConstructionAreaPayload;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author chenwenjian
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/8/9 15:16
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class ConstructionAreaHandler extends AbstractTenantProcedureStatusHandler implements EventHandler, InitializingBean {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EventConsumer eventConsumer;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEvent(Event event, EventConsumer.Context context) {
|
||||||
|
log.info("ConstructionAreaHandler onEvent, event: {}", JSONUtil.toJsonStr(event));
|
||||||
|
// 解析数据
|
||||||
|
ConstructionAreaPayload constructionAreaPayload = event.normalizedData(ConstructionAreaPayload.class);
|
||||||
|
log.info("ConstructionAreaHandler onEvent, payload: {}", JSONUtil.toJsonStr(constructionAreaPayload));
|
||||||
|
// 业务处理:更新对应workspaceId下创建施工区域操作的完成状态
|
||||||
|
updateTenantStatus(constructionAreaPayload.getWorkspaceId(), GuideProcedureEnum.CREATE_CONSTRUCTION_AREA);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterPropertiesSet() throws Exception {
|
||||||
|
Event.EventCode eventCode = new Event.EventCode(MQEventEnum.CONSTRUCTION_AREA.getModel(), MQEventEnum.CONSTRUCTION_AREA.getTag());
|
||||||
|
eventConsumer.registerHandler(eventCode, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
package cn.axzo.nanopart.server.event.data_collection;
|
||||||
|
|
||||||
|
import cn.axzo.framework.rocketmq.Event;
|
||||||
|
import cn.axzo.framework.rocketmq.EventConsumer;
|
||||||
|
import cn.axzo.framework.rocketmq.EventHandler;
|
||||||
|
import cn.axzo.nanopart.server.enums.GuideProcedureEnum;
|
||||||
|
import cn.axzo.nanopart.server.event.AbstractTenantProcedureStatusHandler;
|
||||||
|
import cn.axzo.nanopart.server.event.enums.MQEventEnum;
|
||||||
|
import cn.axzo.nanopart.server.event.payload.DisclosurePayload;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author chenwenjian
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/8/9 16:05
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class DisclosureHandler extends AbstractTenantProcedureStatusHandler implements EventHandler, InitializingBean {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EventConsumer eventConsumer;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEvent(Event event, EventConsumer.Context context) {
|
||||||
|
log.info("DisclosureHandler onEvent, event: {}", JSONUtil.toJsonStr(event));
|
||||||
|
// 解析数据
|
||||||
|
DisclosurePayload disclosurePayload = event.normalizedData(DisclosurePayload.class);
|
||||||
|
log.info("DisclosureHandler onEvent, payload: {}", JSONUtil.toJsonStr(disclosurePayload));
|
||||||
|
// 业务处理:更新对应workspaceId下上传交底操作的完成状态
|
||||||
|
updateTenantStatus(disclosurePayload.getWorkspaceId(), GuideProcedureEnum.DISCLOSURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterPropertiesSet() throws Exception {
|
||||||
|
Event.EventCode eventCode = new Event.EventCode(MQEventEnum.DISCLOSURE.getModel(), MQEventEnum.DISCLOSURE.getTag());
|
||||||
|
eventConsumer.registerHandler(eventCode, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -36,6 +36,10 @@ public enum MQEventEnum {
|
|||||||
WORKSPACE("WORKSPACE", "WORKSPACE", "WORKSPACE"),
|
WORKSPACE("WORKSPACE", "WORKSPACE", "WORKSPACE"),
|
||||||
LABOUR("LABOUR", "LABOUR", "LABOUR"),
|
LABOUR("LABOUR", "LABOUR", "LABOUR"),
|
||||||
|
|
||||||
|
CONSTRUCTION_AREA("construction_area", "construction_area", "创建施工区域"),
|
||||||
|
|
||||||
|
DISCLOSURE("disclosure", "disclosure", "上传交底"),
|
||||||
|
|
||||||
;
|
;
|
||||||
private final String model;
|
private final String model;
|
||||||
private final String tag;
|
private final String tag;
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
package cn.axzo.nanopart.server.event.payload;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 施工区域消息体
|
||||||
|
*
|
||||||
|
* @author chenwenjian
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/8/9 15:18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ConstructionAreaPayload {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private Long workspaceId;
|
||||||
|
|
||||||
|
private Long projectId;
|
||||||
|
}
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
package cn.axzo.nanopart.server.event.payload;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author chenwenjian
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/8/9 15:21
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DisclosurePayload {
|
||||||
|
|
||||||
|
private Long workspaceId;
|
||||||
|
|
||||||
|
private Long templateId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*任务项编码
|
||||||
|
*/
|
||||||
|
private String taskContentCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 交底编码
|
||||||
|
*/
|
||||||
|
private Long code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 区域名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分类,1:分项交底,2:作业交底
|
||||||
|
*/
|
||||||
|
private Integer category;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类别,1:技术,2:安全
|
||||||
|
*/
|
||||||
|
private Integer type;
|
||||||
|
}
|
||||||
@ -113,7 +113,8 @@ public class GuideTenantProcedureStatusServiceImpl extends ServiceImpl<GuideTena
|
|||||||
GuideProcedureTemplateResp byProcedureId = procedureTemplateService.getByProcedureId(req.getProcedureId());
|
GuideProcedureTemplateResp byProcedureId = procedureTemplateService.getByProcedureId(req.getProcedureId());
|
||||||
// 步骤模板不存在
|
// 步骤模板不存在
|
||||||
if (Objects.isNull(byProcedureId)) {
|
if (Objects.isNull(byProcedureId)) {
|
||||||
throw new ServiceException("操作步骤不存在,请联系管理人员");
|
log.error("步骤模板不存在,步骤id:{}", req.getProcedureId());
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
GuideTenantProcedureStatusCreateReq createReq = new GuideTenantProcedureStatusCreateReq();
|
GuideTenantProcedureStatusCreateReq createReq = new GuideTenantProcedureStatusCreateReq();
|
||||||
createReq.setWorkspaceId(req.getWorkspaceId());
|
createReq.setWorkspaceId(req.getWorkspaceId());
|
||||||
@ -125,6 +126,10 @@ public class GuideTenantProcedureStatusServiceImpl extends ServiceImpl<GuideTena
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (Objects.equals(req.getFrom(), 2) && Objects.equals(tenantProcedure.getStatus(), GuideProcedureStatus.FINISHED)) {
|
||||||
|
log.info("步骤已完成,无需重复操作,workspaceId: {}, procedureId:{}", req.getWorkspaceId(), req.getProcedureId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
tenantProcedure.setStatus(req.getStatus());
|
tenantProcedure.setStatus(req.getStatus());
|
||||||
updateById(tenantProcedure);
|
updateById(tenantProcedure);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user