Commit 0182849e authored by suhuiguang's avatar suhuiguang

1.编辑代码公共分析

parent 6da8426b
package com.yeejoin.amos.boot.module.jg.biz.context;
import com.yeejoin.amos.boot.module.jg.biz.event.BaseBizChangeEvent;
import com.yeejoin.amos.boot.module.jg.biz.service.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.strategy.IBizDataChangeHandleStrategy;
import com.yeejoin.amos.boot.module.jg.biz.edit.event.BaseBizDataChangeEvent;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.DefaultBizDataChangeHandler;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
......@@ -17,19 +18,19 @@ import java.util.Optional;
@Component
public class BizDataHandleStrategyContext implements ApplicationContextAware {
private static final Map<String, DefaultBizDataChangeHandler<? extends BaseBizChangeEvent>> dataProcessStrategyHashMap = new HashMap<>();
private static final Map<String, IBizDataChangeHandleStrategy> dataProcessStrategyHashMap = new HashMap<>();
public static DefaultBizDataChangeHandler<? extends BaseBizChangeEvent> getStrategy(String bizType) {
public static IBizDataChangeHandleStrategy getStrategy(String bizType) {
return Optional.ofNullable(dataProcessStrategyHashMap.get(bizType)).orElseThrow(() -> new RuntimeException(String.format("not found %s type strategy", bizType)));
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
Map<String, DefaultBizDataChangeHandler> strategyBeans = applicationContext.getBeansOfType(DefaultBizDataChangeHandler.class);
Map<String, IBizDataChangeHandleStrategy> strategyBeans = applicationContext.getBeansOfType(IBizDataChangeHandleStrategy.class);
if (strategyBeans.isEmpty()) {
return;
}
for (DefaultBizDataChangeHandler<? extends BaseBizChangeEvent> strategy : strategyBeans.values()) {
for (IBizDataChangeHandleStrategy strategy : strategyBeans.values()) {
dataProcessStrategyHashMap.put(strategy.canHandleBizType(), strategy);
}
}
......
package com.yeejoin.amos.boot.module.jg.biz.context;
import com.yeejoin.amos.boot.module.jg.biz.service.IEquipChangeDataProcessStrategy;
import com.yeejoin.amos.boot.module.jg.biz.service.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.equip.strategy.IEquipChangeDataProcessStrategy;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.DefaultBizDataChangeHandler;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
......
package com.yeejoin.amos.boot.module.jg.biz.controller;
import com.yeejoin.amos.boot.module.jg.biz.dto.RequestChangeData;
import com.yeejoin.amos.boot.module.jg.biz.service.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.BizDataChangeServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.jg.biz.edit.BizDataChangeServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.SingleManageEquipEditHandleImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......
......@@ -2,7 +2,7 @@ package com.yeejoin.amos.boot.module.jg.biz.dto;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.biz.service.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.DefaultBizDataChangeHandler;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
package com.yeejoin.amos.boot.module.jg.biz.edit;
import com.yeejoin.amos.boot.module.jg.biz.dto.RequestChangeData;
import com.yeejoin.amos.boot.module.jg.biz.event.BaseBizChangeEvent;
import com.yeejoin.amos.boot.module.jg.biz.service.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.jg.biz.context.BizDataHandleStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.dto.RequestChangeData;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.strategy.IBizDataChangeHandleStrategy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -24,13 +24,12 @@ public class BizDataChangeServiceImpl {
public void save(String applyNo,
String bizType,
RequestChangeData changeData) {
DefaultBizDataChangeHandler.ModelType model = changeData.getModelType();
DefaultBizDataChangeHandler<? extends BaseBizChangeEvent> handleStrategy = BizDataHandleStrategyContext.getStrategy(bizType);
handleStrategy.doSave(applyNo, model, changeData);
IBizDataChangeHandleStrategy handleStrategy = BizDataHandleStrategyContext.getStrategy(bizType);
handleStrategy.doSave(applyNo, changeData.getModelType(), changeData);
}
public Map<String, ?> queryDetail(String applyNo, String bizType, DefaultBizDataChangeHandler.ModelType model, String bizId) {
DefaultBizDataChangeHandler<? extends BaseBizChangeEvent> handleStrategy = BizDataHandleStrategyContext.getStrategy(bizType);
IBizDataChangeHandleStrategy handleStrategy = BizDataHandleStrategyContext.getStrategy(bizType);
return handleStrategy.getDetail(applyNo, model, bizId);
}
......
package com.yeejoin.amos.boot.module.jg.biz.edit.core;
import com.yeejoin.amos.boot.module.jg.biz.edit.event.BaseBizDataChangeEvent;
import lombok.Getter;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;
@Getter
@Component("defaultEventPublisher")
public class DefaultEventPublisher implements IEventPublisher<BaseBizDataChangeEvent>, ApplicationEventPublisherAware {
private ApplicationEventPublisher publisher;
@Override
public void publish(BaseBizDataChangeEvent event) {
publisher.publishEvent(event);
}
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
}
}
package com.yeejoin.amos.boot.module.jg.biz.edit.core;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface EventPublisherMapping {
String value() default "defaultEventPublisher";
}
package com.yeejoin.amos.boot.module.jg.biz.edit.core;
import org.springframework.context.ApplicationEvent;
public interface IEventPublisher<T extends ApplicationEvent> {
void publish(T event);
}
package com.yeejoin.amos.boot.module.jg.biz.edit.core;
import com.yeejoin.amos.boot.module.jg.biz.edit.event.BaseBizDataChangeEvent;
import lombok.RequiredArgsConstructor;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
@Component
@RequiredArgsConstructor
public class RouterEventPublisher implements IEventPublisher<BaseBizDataChangeEvent> {
private final ApplicationContext applicationContext;
private final Map<Class<?>, String> publisherCache = new ConcurrentHashMap<>();
@Override
public void publish(BaseBizDataChangeEvent event) {
String publisherName = resolvePublisherName(event.getClass());
IEventPublisher<BaseBizDataChangeEvent> publisher = applicationContext.getBean(publisherName, IEventPublisher.class);
Optional.of(publisher).ifPresent(publish -> publisher.publish(event));
}
private String resolvePublisherName(Class<?> eventClass) {
return publisherCache.computeIfAbsent(eventClass, clz -> {
EventPublisherMapping annotation = clz.getAnnotation(EventPublisherMapping.class);
return (annotation != null) ? annotation.value() : "defaultEventPublisher";
});
}
}
package com.yeejoin.amos.boot.module.jg.biz.service;
package com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz;
import cn.hutool.extra.spring.SpringUtil;
import com.yeejoin.amos.boot.module.jg.api.dto.ChangeDataDto;
import com.yeejoin.amos.boot.module.jg.biz.context.EquipDataProcessStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.event.BaseBizChangeEvent;
import com.yeejoin.amos.boot.module.jg.biz.event.ChangeDataEvent;
import com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher;
import com.yeejoin.amos.boot.module.jg.biz.edit.core.IEventPublisher;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.strategy.IBizDataChangeHandleStrategy;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.equip.strategy.IEquipChangeDataProcessStrategy;
import com.yeejoin.amos.boot.module.jg.biz.edit.event.BaseBizDataChangeEvent;
import com.yeejoin.amos.boot.module.jg.biz.edit.event.ChangeLogInsertEvent;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.util.List;
import java.util.Map;
public abstract class DefaultBizDataChangeHandler<U extends BaseBizChangeEvent> implements IBizDataChangeHandleStrategy {
public abstract class DefaultBizDataChangeHandler<U extends BaseBizDataChangeEvent> implements IBizDataChangeHandleStrategy {
private final IEventPublisher<BaseBizDataChangeEvent> eventPublisher;
protected DefaultBizDataChangeHandler(IEventPublisher<BaseBizDataChangeEvent> eventPublisher) {
this.eventPublisher = eventPublisher;
}
@Transactional(rollbackFor = Exception.class)
@Override
public void doSave(String applyNo, ModelType model, Map<String, Object> changeData) {
if (beforeCheck(applyNo, model, changeData)) {
IEquipChangeDataProcessStrategy dataProcessor = EquipDataProcessStrategyContext.getStrategy(model);
......@@ -23,7 +31,7 @@ public abstract class DefaultBizDataChangeHandler<U extends BaseBizChangeEvent>
List<ChangeDataDto> bizEditColumns = bizDataSave(applyNo, model, changeData);
allChangeColumns.addAll(bizEditColumns);
// 发送数据变更
publish2OtherBiz(buildEvent(applyNo,model,changeData));
publish2OtherBiz(buildEvent(applyNo, model, changeData));
// 异步记录日志
writeLog(allChangeColumns);
}
......@@ -32,12 +40,10 @@ public abstract class DefaultBizDataChangeHandler<U extends BaseBizChangeEvent>
protected abstract U buildEvent(String applyNo, ModelType model, Map<String, Object> changeData);
private void publish2OtherBiz(U event) {
EventPublisher publisher = SpringUtil.getBean(com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher.class);
publisher.publish(event);
eventPublisher.publish(event);
}
private void writeLog(List<ChangeDataDto> allChangeColumns) {
EventPublisher publisher = SpringUtil.getBean(com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher.class);
publisher.publish(new ChangeDataEvent(this, allChangeColumns, RequestContext.cloneRequestContext()));
eventPublisher.publish(new ChangeLogInsertEvent(this, allChangeColumns, RequestContext.cloneRequestContext()));
}
}
package com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz;
import com.yeejoin.amos.boot.module.jg.api.dto.ChangeDataDto;
import com.yeejoin.amos.boot.module.jg.biz.edit.core.RouterEventPublisher;
import com.yeejoin.amos.boot.module.jg.biz.edit.event.BaseBizDataChangeEvent;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@Component
public class InstallNoticeDataChangeHandleImpl extends DefaultBizDataChangeHandler<BaseBizDataChangeEvent> {
protected InstallNoticeDataChangeHandleImpl(RouterEventPublisher routerEventPublisher) {
super(routerEventPublisher);
}
@Override
protected BaseBizDataChangeEvent buildEvent(String applyNo, ModelType model, Map<String, Object> changeData) {
return new BaseBizDataChangeEvent(this, applyNo, RequestContext.cloneRequestContext());
}
@Override
public String canHandleBizType() {
return "installNotice";
}
@Override
public Map<String, ?> getDetail(String applyNo, ModelType model, String bizId) {
return Collections.emptyMap();
}
@Override
public List<ChangeDataDto> bizDataSave(String applyNo, ModelType model, Map<String, Object> changeData) {
return Collections.emptyList();
}
@Override
public Boolean beforeCheck(String applyNo, ModelType model, Map<String, Object> changeData) {
return null;
}
}
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
package com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz;
import com.yeejoin.amos.boot.module.jg.api.dto.ChangeDataDto;
import com.yeejoin.amos.boot.module.jg.biz.context.EquipDataProcessStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.event.BaseBizChangeEvent;
import com.yeejoin.amos.boot.module.jg.biz.service.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.jg.biz.service.IEquipChangeDataProcessStrategy;
import lombok.RequiredArgsConstructor;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.equip.strategy.IEquipChangeDataProcessStrategy;
import com.yeejoin.amos.boot.module.jg.biz.edit.core.RouterEventPublisher;
import com.yeejoin.amos.boot.module.jg.biz.edit.event.BaseBizDataChangeEvent;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.UseRegisterUpdateService;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.context.RequestContext;
......@@ -14,12 +14,16 @@ import java.util.List;
import java.util.Map;
@Service
@RequiredArgsConstructor
public class UseRegisterDataChangeHandleImpl extends DefaultBizDataChangeHandler<BaseBizChangeEvent> {
public class UseRegisterDataChangeHandleImpl extends DefaultBizDataChangeHandler<BaseBizDataChangeEvent> {
private final UseRegisterUpdateService useRegisterUpdateService;
protected UseRegisterDataChangeHandleImpl(RouterEventPublisher routerEventPublisher, UseRegisterUpdateService useRegisterUpdateService) {
super(routerEventPublisher);
this.useRegisterUpdateService = useRegisterUpdateService;
}
@Override
public String canHandleBizType() {
......@@ -73,8 +77,8 @@ public class UseRegisterDataChangeHandleImpl extends DefaultBizDataChangeHandler
}
@Override
protected BaseBizChangeEvent buildEvent(String applyNo, ModelType model, Map<String, Object> changeData) {
return new BaseBizChangeEvent(this, applyNo, RequestContext.cloneRequestContext());
protected BaseBizDataChangeEvent buildEvent(String applyNo, ModelType model, Map<String, Object> changeData) {
return new BaseBizDataChangeEvent(this, applyNo, RequestContext.cloneRequestContext());
}
}
package com.yeejoin.amos.boot.module.jg.biz.service;
package com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.strategy;
import com.yeejoin.amos.boot.module.jg.api.dto.ChangeDataDto;
import com.yeejoin.amos.boot.module.jg.biz.context.EquipDataProcessStrategyContext;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
......@@ -28,7 +26,6 @@ public interface IBizDataChangeHandleStrategy {
/**
* 保存
*
* @param applyNo 单据编号
* @param model @see ModelType
* @param changeData 变更数据
......@@ -36,6 +33,13 @@ public interface IBizDataChangeHandleStrategy {
List<ChangeDataDto> bizDataSave(String applyNo, ModelType model, Map<String, Object> changeData);
/**
* 前置校验
* @param applyNo 单据编号
* @param model 类型
* @param changeData 数据
* @return 是否通过前置校验
*/
Boolean beforeCheck(String applyNo, ModelType model, Map<String, Object> changeData);
/**
......@@ -48,4 +52,6 @@ public interface IBizDataChangeHandleStrategy {
batchEquip,
batchCylinder
}
void doSave(String applyNo, ModelType model, Map<String, Object> changeData) ;
}
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
package com.yeejoin.amos.boot.module.jg.biz.edit.deal.equip;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.biz.dto.RequestChangeData;
import com.yeejoin.amos.boot.module.jg.biz.service.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.jg.biz.service.IEquipChangeDataProcessStrategy;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.strategy.IBizDataChangeHandleStrategy;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.equip.strategy.IEquipChangeDataProcessStrategy;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
......@@ -16,12 +17,12 @@ import java.util.Map;
* 批量维护气瓶-策略实现类
*/
@Component
public class BatchCylinderDataEquipChangeProcessStrategy implements IEquipChangeDataProcessStrategy {
public class BatchCylinderDataEquipChangeProcess implements IEquipChangeDataProcessStrategy {
private final CommonEquipDataProcessService commonEquipDataProcessService;
public BatchCylinderDataEquipChangeProcessStrategy(CommonEquipDataProcessService commonEquipDataProcessService) {
public BatchCylinderDataEquipChangeProcess(CommonEquipDataProcessService commonEquipDataProcessService) {
this.commonEquipDataProcessService = commonEquipDataProcessService;
}
......@@ -116,7 +117,7 @@ public class BatchCylinderDataEquipChangeProcessStrategy implements IEquipChange
@Override
public DefaultBizDataChangeHandler.ModelType canHandleMode() {
public IBizDataChangeHandleStrategy.ModelType canHandleMode() {
return DefaultBizDataChangeHandler.ModelType.batchCylinder;
}
}
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
package com.yeejoin.amos.boot.module.jg.biz.edit.deal.equip;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.biz.dto.RequestChangeData;
import com.yeejoin.amos.boot.module.jg.biz.service.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.jg.biz.service.IEquipChangeDataProcessStrategy;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.strategy.IBizDataChangeHandleStrategy;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.equip.strategy.IEquipChangeDataProcessStrategy;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
......@@ -16,12 +17,12 @@ import java.util.Map;
* 批量维护设备-策略实现类
*/
@Component
public class BatchEquipDataEquipChangeProcessStrategy implements IEquipChangeDataProcessStrategy {
public class BatchEquipDataEquipChangeProcess implements IEquipChangeDataProcessStrategy {
private final CommonEquipDataProcessService commonEquipDataProcessService;
public BatchEquipDataEquipChangeProcessStrategy(CommonEquipDataProcessService commonEquipDataProcessService) {
public BatchEquipDataEquipChangeProcess(CommonEquipDataProcessService commonEquipDataProcessService) {
this.commonEquipDataProcessService = commonEquipDataProcessService;
}
......@@ -68,7 +69,7 @@ public class BatchEquipDataEquipChangeProcessStrategy implements IEquipChangeDat
@Override
public DefaultBizDataChangeHandler.ModelType canHandleMode() {
public IBizDataChangeHandleStrategy.ModelType canHandleMode() {
return DefaultBizDataChangeHandler.ModelType.batchEquip;
}
}
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
package com.yeejoin.amos.boot.module.jg.biz.edit.deal.equip;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.biz.dto.RequestChangeData;
import com.yeejoin.amos.boot.module.jg.biz.service.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.jg.biz.service.IEquipChangeDataProcessStrategy;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.strategy.IBizDataChangeHandleStrategy;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.equip.strategy.IEquipChangeDataProcessStrategy;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
......@@ -20,7 +21,7 @@ import java.util.Map;
*/
@Component
@RequiredArgsConstructor
public class BatchProjectDataEquipChangeProcessStrategy implements IEquipChangeDataProcessStrategy {
public class BatchProjectDataEquipChangeProcess implements IEquipChangeDataProcessStrategy {
private final CommonEquipDataProcessService commonEquipDataProcessService;
......@@ -102,7 +103,7 @@ public class BatchProjectDataEquipChangeProcessStrategy implements IEquipChangeD
}
@Override
public DefaultBizDataChangeHandler.ModelType canHandleMode() {
public IBizDataChangeHandleStrategy.ModelType canHandleMode() {
return DefaultBizDataChangeHandler.ModelType.batchProject;
}
}
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
package com.yeejoin.amos.boot.module.jg.biz.edit.deal.equip;
import cn.hutool.core.bean.BeanUtil;
......@@ -11,6 +11,8 @@ import com.yeejoin.amos.boot.biz.common.annotation.FieldDisplayDefine;
import com.yeejoin.amos.boot.biz.common.annotation.Group;
import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.biz.service.*;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgUseInfoServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgUseRegistrationServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgDesignInfoMapper;
......@@ -52,7 +54,7 @@ public class CommonEquipDataProcessService {
private final IIdxBizJgTechParamsLiftingService iIdxBizJgTechParamsLiftingService;
private final EquipChangeDataUpdateService equipChangeDataUpdateService;
private final EquipChangeDataUpdateServiceImpl equipChangeDataUpdateServiceImpl;
private final IdxBizJgUseInfoServiceImpl idxBizJgUseInfoService;
......@@ -124,21 +126,21 @@ public class CommonEquipDataProcessService {
// 注册信息
if (changeDataDto instanceof EquipRegisterChangeDataDto) {
EquipRegisterChangeDataDto registerChangeDataDto = (EquipRegisterChangeDataDto) changeDataDto;
equipChangeDataUpdateService.checkRegisterChangeData(record, registerChangeDataDto);
equipChangeDataUpdateServiceImpl.checkRegisterChangeData(record, registerChangeDataDto);
}
// 制造信息
if (changeDataDto instanceof EquipFactoryChangeDataDto) {
EquipFactoryChangeDataDto equipFactoryChangeDataDto = (EquipFactoryChangeDataDto) changeDataDto;
equipChangeDataUpdateService.checkFactoryChangeData(record, equipFactoryChangeDataDto, equList, equCategory, equDefine);
equipChangeDataUpdateServiceImpl.checkFactoryChangeData(record, equipFactoryChangeDataDto, equList, equCategory, equDefine);
}
// 设计信息
if (changeDataDto instanceof EquipDesignChangeDataDto) {
EquipDesignChangeDataDto equipDesignChangeDataDto = (EquipDesignChangeDataDto) changeDataDto;
equipChangeDataUpdateService.checkDesignChangeData(record, equipDesignChangeDataDto);
equipChangeDataUpdateServiceImpl.checkDesignChangeData(record, equipDesignChangeDataDto);
}
}
void buildChangeFields(String record, EquipDesignChangeDataDto equipDesignChangeDataDto, EquipFactoryChangeDataDto equipFactoryChangeDataDto, EquipRegisterChangeDataDto registerChangeDataDto, List<ChangeDataDto> allChangeColumns) {
public void buildChangeFields(String record, EquipDesignChangeDataDto equipDesignChangeDataDto, EquipFactoryChangeDataDto equipFactoryChangeDataDto, EquipRegisterChangeDataDto registerChangeDataDto, List<ChangeDataDto> allChangeColumns) {
// 构造新对象行转列
List<ChangeDataDto> designInfoNew = this.convertBeanField2Column2(equipDesignChangeDataDto, record);
List<ChangeDataDto> factoryInfoNew = this.convertBeanField2Column2(equipFactoryChangeDataDto, record);
......@@ -152,7 +154,7 @@ public class CommonEquipDataProcessService {
allChangeColumns.addAll(this.mergeChangeFields(registerInfoNew, registerInfoOld));
}
void buildChangeFields(String record, EquipDesignChangeDataDto equipDesignChangeDataDto, EquipFactoryChangeDataDto equipFactoryChangeDataDto, EquipRegisterChangeDataDto registerChangeDataDto, EquipUseInfoChangeDataDto useInfoChangeDataDto, List<ChangeDataDto> allChangeColumns) {
public void buildChangeFields(String record, EquipDesignChangeDataDto equipDesignChangeDataDto, EquipFactoryChangeDataDto equipFactoryChangeDataDto, EquipRegisterChangeDataDto registerChangeDataDto, EquipUseInfoChangeDataDto useInfoChangeDataDto, List<ChangeDataDto> allChangeColumns) {
// 构造新对象行转列
List<ChangeDataDto> designInfoNew = this.convertBeanField2Column2(equipDesignChangeDataDto, record);
List<ChangeDataDto> factoryInfoNew = this.convertBeanField2Column2(equipFactoryChangeDataDto, record);
......@@ -175,31 +177,31 @@ public class CommonEquipDataProcessService {
* @param record 设备主键
* @param changeDataDto 变更后数据
*/
void dealBizDataForEquip(String record, BaseChangeDataDto changeDataDto) {
public void dealBizDataForEquip(String record, BaseChangeDataDto changeDataDto) {
// 注册信息
if (changeDataDto instanceof EquipRegisterChangeDataDto) {
EquipRegisterChangeDataDto registerChangeDataDto = (EquipRegisterChangeDataDto) changeDataDto;
equipChangeDataUpdateService.updateRegisterChangeData(record, registerChangeDataDto);
equipChangeDataUpdateServiceImpl.updateRegisterChangeData(record, registerChangeDataDto);
}
// 制造信息
if (changeDataDto instanceof EquipFactoryChangeDataDto) {
EquipFactoryChangeDataDto equipFactoryChangeDataDto = (EquipFactoryChangeDataDto) changeDataDto;
equipChangeDataUpdateService.updateFactoryChangeData(record, equipFactoryChangeDataDto);
equipChangeDataUpdateServiceImpl.updateFactoryChangeData(record, equipFactoryChangeDataDto);
}
// 设计信息
if (changeDataDto instanceof EquipDesignChangeDataDto) {
EquipDesignChangeDataDto equipDesignChangeDataDto = (EquipDesignChangeDataDto) changeDataDto;
equipChangeDataUpdateService.updateDesignChangeData(record, equipDesignChangeDataDto);
equipChangeDataUpdateServiceImpl.updateDesignChangeData(record, equipDesignChangeDataDto);
}
// 使用信息
if (changeDataDto instanceof EquipUseInfoChangeDataDto) {
EquipUseInfoChangeDataDto equipUseInfoChangeDataDto = (EquipUseInfoChangeDataDto) changeDataDto;
equipChangeDataUpdateService.updateUseInfoChangeData(record, equipUseInfoChangeDataDto);
equipChangeDataUpdateServiceImpl.updateUseInfoChangeData(record, equipUseInfoChangeDataDto);
}
// 检验信息
if(changeDataDto instanceof EquipInspectChangeDataDto){
EquipInspectChangeDataDto equipUseInfoChangeDataDto = (EquipInspectChangeDataDto) changeDataDto;
equipChangeDataUpdateService.updateOrSaveInspectInfo(record, equipUseInfoChangeDataDto);
equipChangeDataUpdateServiceImpl.updateOrSaveInspectInfo(record, equipUseInfoChangeDataDto);
}
}
......@@ -283,7 +285,7 @@ public class CommonEquipDataProcessService {
}
void updateTechParamInfo(EquipRegisterChangeDataDto equipRegisterChangeDataDto, String record, Map<String, Object> changeData, List<ChangeDataDto> allChange) {
public void updateTechParamInfo(EquipRegisterChangeDataDto equipRegisterChangeDataDto, String record, Map<String, Object> changeData, List<ChangeDataDto> allChange) {
EquipmentClassifityEnum equipmentClassifityEnum = EquipmentClassifityEnum.getOne(equipRegisterChangeDataDto.getEquList());
switch (Objects.requireNonNull(equipmentClassifityEnum)) {
case GL:
......@@ -296,7 +298,7 @@ public class CommonEquipDataProcessService {
// 比对
List<ChangeDataDto> boilerChangeFields = this.mergeChangeFields(boilerChangeDataNew, boilerChangeDataOld);
// 业务处理
equipChangeDataUpdateService.updateTechParamByRecord(this.buildTableName(TechParamsBoilerChangeFieldDto.class), record, boilerChangeFields);
equipChangeDataUpdateServiceImpl.updateTechParamByRecord(this.buildTableName(TechParamsBoilerChangeFieldDto.class), record, boilerChangeFields);
// 日志数据记录
allChange.addAll(boilerChangeDataNew);
break;
......@@ -312,7 +314,7 @@ public class CommonEquipDataProcessService {
// 比对
List<ChangeDataDto> vesselChangeFields = this.mergeChangeFields(newVesselChangeData, oldVesselChangeData);
// 业务处理
equipChangeDataUpdateService.updateTechParamByRecord(this.buildTableName(TechParamsVesselChangeFieldDto.class), record, vesselChangeFields);
equipChangeDataUpdateServiceImpl.updateTechParamByRecord(this.buildTableName(TechParamsVesselChangeFieldDto.class), record, vesselChangeFields);
// 日志数据记录
allChange.addAll(vesselChangeFields);
break;
......@@ -329,7 +331,7 @@ public class CommonEquipDataProcessService {
// 比对
List<ChangeDataDto> elevatorChangeFields = this.mergeChangeFields(newElevatorChangeData, oldElevatorChangeData);
// 业务处理
equipChangeDataUpdateService.updateTechParamByRecord(this.buildTableName(TechParamsElevatorChangeFieldDto.class), record, elevatorChangeFields);
equipChangeDataUpdateServiceImpl.updateTechParamByRecord(this.buildTableName(TechParamsElevatorChangeFieldDto.class), record, elevatorChangeFields);
// 日志数据记录
allChange.addAll(elevatorChangeFields);
break;
......@@ -347,7 +349,7 @@ public class CommonEquipDataProcessService {
// 比对
List<ChangeDataDto> liftingChangeFields = this.mergeChangeFields(newLiftingChangeData, oldLiftingChangeData);
// 业务处理
equipChangeDataUpdateService.updateTechParamByRecord(this.buildTableName(TechParamsLiftingChangeFieldDto.class), record, liftingChangeFields);
equipChangeDataUpdateServiceImpl.updateTechParamByRecord(this.buildTableName(TechParamsLiftingChangeFieldDto.class), record, liftingChangeFields);
// 日志数据记录
allChange.addAll(liftingChangeFields);
break;
......@@ -364,7 +366,7 @@ public class CommonEquipDataProcessService {
// 比对
List<ChangeDataDto> vehicleChangeFields = this.mergeChangeFields(newVehicleChangeData, oldVehicleChangeData);
// 业务处理
equipChangeDataUpdateService.updateTechParamByRecord(this.buildTableName(TechParamsVehicleChangeFieldDto.class), record, vehicleChangeFields);
equipChangeDataUpdateServiceImpl.updateTechParamByRecord(this.buildTableName(TechParamsVehicleChangeFieldDto.class), record, vehicleChangeFields);
// 日志数据记录
allChange.addAll(vehicleChangeFields);
break;
......@@ -382,7 +384,7 @@ public class CommonEquipDataProcessService {
// 比对
List<ChangeDataDto> ridesChangeFields = this.mergeChangeFields(newRidesChangeData, oldRidesChangeData);
// 业务处理
equipChangeDataUpdateService.updateTechParamByRecord(this.buildTableName(TechParamsRidesChangeFieldDto.class), record, ridesChangeFields);
equipChangeDataUpdateServiceImpl.updateTechParamByRecord(this.buildTableName(TechParamsRidesChangeFieldDto.class), record, ridesChangeFields);
// 日志数据记录
allChange.addAll(ridesChangeFields);
break;
......@@ -406,7 +408,7 @@ public class CommonEquipDataProcessService {
// 比对
List<ChangeDataDto> ropewayChangeFields = this.mergeChangeFields(newRopewayChangeData, oldRopewayChangeData);
// 业务处理
equipChangeDataUpdateService.updateTechParamByRecord(this.buildTableName(TechParamsRopewayChangeFieldDto.class), record, ropewayChangeFields);
equipChangeDataUpdateServiceImpl.updateTechParamByRecord(this.buildTableName(TechParamsRopewayChangeFieldDto.class), record, ropewayChangeFields);
// 日志数据记录
allChange.addAll(ropewayChangeFields);
break;
......@@ -425,7 +427,7 @@ public class CommonEquipDataProcessService {
// 比对
List<ChangeDataDto> pipelineChangeFields = this.mergeChangeFields(newPipelineChangeData, oldPipelineChangeData);
// 业务处理
equipChangeDataUpdateService.updateTechParamByRecord(this.buildTableName(TechParamsPipelineChangeFieldDto.class), record, pipelineChangeFields);
equipChangeDataUpdateServiceImpl.updateTechParamByRecord(this.buildTableName(TechParamsPipelineChangeFieldDto.class), record, pipelineChangeFields);
// 日志数据记录
allChange.addAll(pipelineChangeFields);
}
......@@ -496,7 +498,7 @@ public class CommonEquipDataProcessService {
}
Map<String, Object> cast2UnderCase(Map<String, Object> re) {
public Map<String, Object> cast2UnderCase(Map<String, Object> re) {
// 由于历史遗留问题,和前端保存统一,要转成大写下滑线驼峰
Map<String, Object> result = new HashMap<>();
re.forEach((k, v) -> {
......@@ -505,7 +507,7 @@ public class CommonEquipDataProcessService {
return result;
}
void castJsonFields(Map<String, Object> re) {
public void castJsonFields(Map<String, Object> re) {
jsonFields.forEach(field -> {
if (re.containsKey(field) && re.get(field) instanceof String) {
re.put(field, JSON.parse((String) re.get(field)));
......@@ -513,7 +515,7 @@ public class CommonEquipDataProcessService {
});
}
EquipDesignChangeDataDto buildDesignInfo(String record) {
public EquipDesignChangeDataDto buildDesignInfo(String record) {
EquipDesignChangeDataDto changeDataDto = new EquipDesignChangeDataDto();
IdxBizJgDesignInfo designInfo = idxBizJgDesignInfoMapper.selectOne(new LambdaQueryWrapper<IdxBizJgDesignInfo>().eq(IdxBizJgDesignInfo::getRecord, record));
BeanUtil.copyProperties(designInfo, changeDataDto);
......@@ -521,7 +523,7 @@ public class CommonEquipDataProcessService {
return changeDataDto;
}
EquipFactoryChangeDataDto buildFactoryInfo(String record) {
public EquipFactoryChangeDataDto buildFactoryInfo(String record) {
EquipFactoryChangeDataDto changeDataDto = new EquipFactoryChangeDataDto();
IdxBizJgFactoryInfo factoryInfo = jgFactoryInfoMapper.selectOne(new LambdaQueryWrapper<IdxBizJgFactoryInfo>().eq(IdxBizJgFactoryInfo::getRecord, record));
BeanUtil.copyProperties(factoryInfo, changeDataDto);
......@@ -529,14 +531,14 @@ public class CommonEquipDataProcessService {
return changeDataDto;
}
EquipRegisterChangeDataDto buildRegisterInfo(String record) {
public EquipRegisterChangeDataDto buildRegisterInfo(String record) {
EquipRegisterChangeDataDto changeDataDto = new EquipRegisterChangeDataDto();
IdxBizJgRegisterInfo registerInfo = idxBizJgRegisterInfoMapper.selectOne(new LambdaQueryWrapper<IdxBizJgRegisterInfo>().eq(IdxBizJgRegisterInfo::getRecord, record));
BeanUtil.copyProperties(registerInfo, changeDataDto);
return changeDataDto;
}
EquipUseInfoChangeDataDto buildUseInfo(String record) {
public EquipUseInfoChangeDataDto buildUseInfo(String record) {
EquipUseInfoChangeDataDto changeDataDto = new EquipUseInfoChangeDataDto();
IdxBizJgUseInfo useInfo = idxBizJgUseInfoService.getOneData(record);
BeanUtil.copyProperties(useInfo, changeDataDto);
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
package com.yeejoin.amos.boot.module.jg.biz.edit.deal.equip;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
......@@ -11,6 +11,7 @@ import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.enums.CylinderTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgUseInfoServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquCodeTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
......@@ -27,7 +28,7 @@ import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
public class EquipChangeDataUpdateService {
public class EquipChangeDataUpdateServiceImpl {
private final ESEquipmentCategory esEquipmentCategory;
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
package com.yeejoin.amos.boot.module.jg.biz.edit.deal.equip;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
......@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.module.jg.api.dto.ChangeDataDto;
import com.yeejoin.amos.boot.module.jg.api.dto.PieLineDesignChangeDataDto;
import com.yeejoin.amos.boot.module.jg.api.dto.PipelineChangeItemDto;
import com.yeejoin.amos.boot.module.jg.api.dto.ProjectContraptionChangeDataDto;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgProjectContraptionServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption;
import org.springframework.stereotype.Component;
......@@ -19,12 +20,12 @@ public class PieLineDataChangeServiceImpl {
private final IdxBizJgProjectContraptionServiceImpl idxBizJgProjectContraptionServiceImpl;
private final EquipChangeDataUpdateService equipChangeDataUpdateService;
private final EquipChangeDataUpdateServiceImpl equipChangeDataUpdateServiceImpl;
public PieLineDataChangeServiceImpl(CommonEquipDataProcessService commonEquipDataProcessService, IdxBizJgProjectContraptionServiceImpl idxBizJgProjectContraptionServiceImpl, EquipChangeDataUpdateService equipChangeDataUpdateService) {
public PieLineDataChangeServiceImpl(CommonEquipDataProcessService commonEquipDataProcessService, IdxBizJgProjectContraptionServiceImpl idxBizJgProjectContraptionServiceImpl, EquipChangeDataUpdateServiceImpl equipChangeDataUpdateServiceImpl) {
this.commonEquipDataProcessService = commonEquipDataProcessService;
this.idxBizJgProjectContraptionServiceImpl = idxBizJgProjectContraptionServiceImpl;
this.equipChangeDataUpdateService = equipChangeDataUpdateService;
this.equipChangeDataUpdateServiceImpl = equipChangeDataUpdateServiceImpl;
}
public void update(ProjectContraptionChangeDataDto projectContraptionChangeDataDtoNew, List<ChangeDataDto> allChangeColumns) {
......@@ -61,11 +62,11 @@ public class PieLineDataChangeServiceImpl {
List<ChangeDataDto> designInfoOld = commonEquipDataProcessService.buildDesignInfoOld(record);
allChangeColumns.addAll(commonEquipDataProcessService.mergeChangeFields(designInfoNew, designInfoOld));
// 2.更新管道的设计单位名称
equipChangeDataUpdateService.updatePieLineDesignData(record, pieLineDesignChangeDataDto);
equipChangeDataUpdateServiceImpl.updatePieLineDesignData(record, pieLineDesignChangeDataDto);
}
public void updateEs(ProjectContraptionChangeDataDto projectContraptionChangeDataDto) {
equipChangeDataUpdateService.updateRegisterEsDataPieLine(projectContraptionChangeDataDto);
equipChangeDataUpdateServiceImpl.updateRegisterEsDataPieLine(projectContraptionChangeDataDto);
}
public void deletePieLineBatch(List<PipelineChangeItemDto> deletedPieLines, List<ChangeDataDto> allChangeColumns, String applyNo) {
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
package com.yeejoin.amos.boot.module.jg.biz.edit.deal.equip;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
......@@ -10,8 +10,10 @@ import com.yeejoin.amos.boot.module.jg.api.dto.EquipRegisterChangeDataDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistration;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistrationEq;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationEqMapper;
import com.yeejoin.amos.boot.module.jg.biz.service.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.jg.biz.service.IEquipChangeDataProcessStrategy;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.strategy.IBizDataChangeHandleStrategy;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.equip.strategy.IEquipChangeDataProcessStrategy;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgUseRegistrationServiceImpl;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
......@@ -22,7 +24,7 @@ import java.util.Map;
* 单个维护设备-策略实现类
*/
@Component
public class SingleEquipEquipChangeProcessStrategy implements IEquipChangeDataProcessStrategy {
public class SingleEquipEquipChangeProcess implements IEquipChangeDataProcessStrategy {
private final JgUseRegistrationServiceImpl useRegistrationService;
......@@ -32,7 +34,7 @@ public class SingleEquipEquipChangeProcessStrategy implements IEquipChangeDataPr
private final CommonEquipDataProcessService commonEquipDataProcessService;
public SingleEquipEquipChangeProcessStrategy(JgUseRegistrationServiceImpl useRegistrationService, JgUseRegistrationEqMapper jgRelationEquipMapper, CommonEquipDataProcessService commonEquipDataProcessService) {
public SingleEquipEquipChangeProcess(JgUseRegistrationServiceImpl useRegistrationService, JgUseRegistrationEqMapper jgRelationEquipMapper, CommonEquipDataProcessService commonEquipDataProcessService) {
this.useRegistrationService = useRegistrationService;
this.jgRelationEquipMapper = jgRelationEquipMapper;
this.commonEquipDataProcessService = commonEquipDataProcessService;
......@@ -73,7 +75,7 @@ public class SingleEquipEquipChangeProcessStrategy implements IEquipChangeDataPr
}
@Override
public DefaultBizDataChangeHandler.ModelType canHandleMode() {
public IBizDataChangeHandleStrategy.ModelType canHandleMode() {
return DefaultBizDataChangeHandler.ModelType.singleEquip;
}
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
package com.yeejoin.amos.boot.module.jg.biz.edit.deal.equip;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.text.CharSequenceUtil;
......@@ -6,8 +6,9 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.biz.dto.RequestChangeData;
import com.yeejoin.amos.boot.module.jg.biz.service.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.jg.biz.service.IEquipChangeDataProcessStrategy;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.DefaultBizDataChangeHandler;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.strategy.IBizDataChangeHandleStrategy;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.equip.strategy.IEquipChangeDataProcessStrategy;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
......@@ -22,7 +23,7 @@ import java.util.Map;
*/
@Component
@RequiredArgsConstructor
public class SingleProjectDataEquipChangeProcessStrategy implements IEquipChangeDataProcessStrategy {
public class SingleProjectDataEquipChangeProcess implements IEquipChangeDataProcessStrategy {
private final CommonEquipDataProcessService commonEquipDataProcessService;
......@@ -75,7 +76,7 @@ public class SingleProjectDataEquipChangeProcessStrategy implements IEquipChange
@Override
public DefaultBizDataChangeHandler.ModelType canHandleMode() {
public IBizDataChangeHandleStrategy.ModelType canHandleMode() {
return DefaultBizDataChangeHandler.ModelType.singleProject;
}
}
package com.yeejoin.amos.boot.module.jg.biz.service;
package com.yeejoin.amos.boot.module.jg.biz.edit.deal.equip.strategy;
import com.yeejoin.amos.boot.module.jg.api.dto.ChangeDataDto;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.biz.strategy.IBizDataChangeHandleStrategy;
import java.util.List;
import java.util.Map;
......@@ -20,5 +21,5 @@ public interface IEquipChangeDataProcessStrategy {
*
* @return 可处理的类型
*/
DefaultBizDataChangeHandler.ModelType canHandleMode();
IBizDataChangeHandleStrategy.ModelType canHandleMode();
}
package com.yeejoin.amos.boot.module.jg.biz.event;
package com.yeejoin.amos.boot.module.jg.biz.edit.event;
import lombok.Getter;
import org.springframework.context.ApplicationEvent;
import org.typroject.tyboot.core.foundation.context.RequestContextModel;
@Getter
public class BaseBizChangeEvent extends ApplicationEvent {
public class BaseBizDataChangeEvent extends ApplicationEvent {
private final String applyNo;
private String applyNo;
private RequestContextModel requestContext;
public BaseBizDataChangeEvent(Object source) {
super(source);
}
private final RequestContextModel requestContext;
/**
* Create a new {@code ApplicationEvent}.
*
* @param source the object on which the event initially occurred or with
* which the event is associated (never {@code null})
*/
public BaseBizChangeEvent(Object source, String applyNo, RequestContextModel requestContext) {
public BaseBizDataChangeEvent(Object source, String applyNo, RequestContextModel requestContext) {
super(source);
this.applyNo = applyNo;
this.requestContext = requestContext;
......
package com.yeejoin.amos.boot.module.jg.biz.event;
package com.yeejoin.amos.boot.module.jg.biz.edit.event;
import com.yeejoin.amos.boot.module.jg.api.dto.ChangeDataDto;
import lombok.Getter;
import org.springframework.context.ApplicationEvent;
import org.typroject.tyboot.core.foundation.context.RequestContextModel;
import java.util.List;
......@@ -11,7 +10,7 @@ import java.util.List;
* @author Administrator
*/
@Getter
public class ChangeDataEvent extends ApplicationEvent {
public class ChangeLogInsertEvent extends BaseBizDataChangeEvent {
private final List<ChangeDataDto> data;
......@@ -23,7 +22,7 @@ public class ChangeDataEvent extends ApplicationEvent {
* @param source the object on which the event initially occurred or with
* which the event is associated (never {@code null})
*/
public ChangeDataEvent(Object source, List<ChangeDataDto> data, RequestContextModel requestContext) {
public ChangeLogInsertEvent(Object source, List<ChangeDataDto> data, RequestContextModel requestContext) {
super(source);
this.data = data;
this.requestContext = requestContext;
......
package com.yeejoin.amos.boot.module.jg.biz.event.listener;
package com.yeejoin.amos.boot.module.jg.biz.edit.listener;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.api.dto.ChangeDataDto;
import com.yeejoin.amos.boot.module.jg.api.dto.ESDataChangeLogDto;
import com.yeejoin.amos.boot.module.jg.biz.dao.ESDataChangeLogDao;
import com.yeejoin.amos.boot.module.jg.biz.event.ChangeDataEvent;
import com.yeejoin.amos.boot.module.jg.biz.edit.event.ChangeLogInsertEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.event.EventListener;
......@@ -26,22 +26,22 @@ import java.util.stream.Collectors;
*/
@Component
@Slf4j
public class ChangeDataEventListener {
public class ChangeLogInsertEventListener {
@Value("${changeData.deal.thread.number:1}")
private int threadNumber;
private final ESDataChangeLogDao esDataChangeLogDao;
private final BlockingQueue<ChangeDataEvent> queue = new LinkedBlockingQueue<>();
private final BlockingQueue<ChangeLogInsertEvent> queue = new LinkedBlockingQueue<>();
public ChangeDataEventListener(ESDataChangeLogDao esDataChangeLogDao) {
public ChangeLogInsertEventListener(ESDataChangeLogDao esDataChangeLogDao) {
this.esDataChangeLogDao = esDataChangeLogDao;
}
@EventListener(value = ChangeDataEvent.class)
public void handleTransactionalEvent(ChangeDataEvent event) {
@EventListener(value = ChangeLogInsertEvent.class)
public void handleTransactionalEvent(ChangeLogInsertEvent event) {
log.info("收到用户变更业务数据消息:{}", JSONObject.toJSONString(event));
queue.add(event);
}
......@@ -53,7 +53,7 @@ public class ChangeDataEventListener {
executorService.execute(() -> {
while (true) {
try {
ChangeDataEvent event = queue.take();
ChangeLogInsertEvent event = queue.take();
this.dealData(event);
} catch (Exception e) {
log.error(e.getMessage(), e);
......@@ -64,7 +64,7 @@ public class ChangeDataEventListener {
}
}
private void dealData(ChangeDataEvent event) {
private void dealData(ChangeLogInsertEvent event) {
List<ChangeDataDto> changeDataDtos = event.getData();
RequestContextModel requestContextModel = event.getRequestContext();
Date date = new Date();
......
......@@ -2,7 +2,8 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.biz.event.ChangeDataEvent;
import com.yeejoin.amos.boot.module.jg.biz.edit.deal.equip.CommonEquipDataProcessService;
import com.yeejoin.amos.boot.module.jg.biz.edit.event.ChangeLogInsertEvent;
import com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
......@@ -52,7 +53,7 @@ public class SingleManageEquipEditHandleImpl {
// 更新历史的JSON的数据
this.buildLogData(allChangeColumns);
// 异步记录日志
publisher.publish(new ChangeDataEvent(this, allChangeColumns, RequestContext.cloneRequestContext()));
publisher.publish(new ChangeLogInsertEvent(this, allChangeColumns, RequestContext.cloneRequestContext()));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment