Merge branch 'dev' of yunhao.wang/i3plus-core into dev
commit
9981d7666b
@ -0,0 +1,34 @@
|
|||||||
|
package cn.estsh.i3plus.core.apiservice.mq;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.core.apiservice.serviceimpl.mdm.SysToolSyncDataService;
|
||||||
|
import cn.estsh.i3plus.pojo.mdm.bean.busi.core.MdmGearCoreBusiExtd;
|
||||||
|
import com.rabbitmq.client.Channel;
|
||||||
|
import org.springframework.amqp.core.Message;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import static cn.estsh.i3plus.platform.common.util.MdmConstWords.QUEUE_MDM_SYNC_DATA_CORE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description :
|
||||||
|
* @Reference :
|
||||||
|
* @Author : yunhao
|
||||||
|
* @CreateDate : 2020-05-28 16:54
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
@Component
|
||||||
|
public class MdmDataSyncQueueReceiver extends BaseMdmDataSyncQueueReceiver {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化类关系
|
||||||
|
*/
|
||||||
|
public MdmDataSyncQueueReceiver() {
|
||||||
|
putMdmDataRef(SysToolSyncDataService.class, MdmGearCoreBusiExtd.mdmMasterClass, MdmGearCoreBusiExtd.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@RabbitListener(queues = QUEUE_MDM_SYNC_DATA_CORE)
|
||||||
|
public void syncMasterData(String syncDataStr, Channel channel, Message message) {
|
||||||
|
processSyncMasterData(syncDataStr, channel, message);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,139 @@
|
|||||||
|
package cn.estsh.i3plus.core.apiservice.serviceimpl.base;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.icloud.mdm.sdk.base.IBaseMdmBusiExtdCloud;
|
||||||
|
import cn.estsh.i3plus.icloud.mdm.sdk.base.IBaseMdmBusiModelCloud;
|
||||||
|
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
|
||||||
|
import cn.estsh.i3plus.pojo.base.bean.BaseResultBean;
|
||||||
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||||
|
import cn.estsh.i3plus.pojo.mdm.bean.base.BaseMdmBusiModelBean;
|
||||||
|
import cn.estsh.i3plus.pojo.mdm.bean.base.MdmSyncData;
|
||||||
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : 业务同步setvice
|
||||||
|
* @Reference :
|
||||||
|
* @Author : yunhao
|
||||||
|
* @CreateDate : 2020-05-15 17:58
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
public abstract class BaseBusiSyncMdmDataService<T, M extends BaseMdmBusiModelBean> {
|
||||||
|
|
||||||
|
private IBaseMdmBusiExtdCloud baseMdmBusiExtdCloud;
|
||||||
|
|
||||||
|
private IBaseMdmBusiModelCloud<M> baseMdmBusiModelCloud;
|
||||||
|
|
||||||
|
public BaseBusiSyncMdmDataService(IBaseMdmBusiExtdCloud baseMdmBusiExtdCloud, IBaseMdmBusiModelCloud<M> baseMdmBusiModelCloud) {
|
||||||
|
this.baseMdmBusiExtdCloud = baseMdmBusiExtdCloud;
|
||||||
|
this.baseMdmBusiModelCloud = baseMdmBusiModelCloud;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主数据新增同步
|
||||||
|
* @param syncData
|
||||||
|
*/
|
||||||
|
public void masterInsertSync(MdmSyncData syncData) {
|
||||||
|
baseMdmBusiExtdCloud.whiteDoProcessMissBusiExtdByMaster(syncData.getSyncDataId().toArray(new Long[syncData.getSyncDataId().size()]), syncData.getSyncDateUserName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主数据修改同步
|
||||||
|
* @param syncData
|
||||||
|
*/
|
||||||
|
public void masterUpdateSync(MdmSyncData syncData) {
|
||||||
|
BaseResultBean<M> baseResultBean =
|
||||||
|
baseMdmBusiModelCloud.whiteFindByMasterIds(syncData.getSyncDataId().toArray(new Long[syncData.getSyncDataId().size()]));
|
||||||
|
if (!baseResultBean.isSuccess()) {
|
||||||
|
throw ImppExceptionBuilder.newInstance()
|
||||||
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.MDM.getCode())
|
||||||
|
.setErrorCode(ImppExceptionEnum.CLOUD_CALL_EXCEPTION.getCode())
|
||||||
|
.setErrorDetail(baseResultBean.getErrorMsg())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<M> modelBeanList = baseResultBean.getResultList();
|
||||||
|
updateBusiList(transform(modelBeanList));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主数据删除同步
|
||||||
|
* @param syncData
|
||||||
|
*/
|
||||||
|
public void masterDeleteSync(MdmSyncData syncData) {
|
||||||
|
baseMdmBusiExtdCloud.whiteDeleteWeaklyByMasterIds(syncData.getSyncDataId().toArray(new Long[syncData.getSyncDataId().size()]),syncData.getSyncDateUserName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务数据新增同步
|
||||||
|
* @param syncData
|
||||||
|
*/
|
||||||
|
public void busiInsertSync(MdmSyncData syncData){
|
||||||
|
BaseResultBean<M> baseResultBean =
|
||||||
|
baseMdmBusiModelCloud.whiteFindByIds(syncData.getSyncDataId().toArray(new Long[syncData.getSyncDataId().size()]));
|
||||||
|
if (!baseResultBean.isSuccess()) {
|
||||||
|
throw ImppExceptionBuilder.newInstance()
|
||||||
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.MDM.getCode())
|
||||||
|
.setErrorCode(ImppExceptionEnum.CLOUD_CALL_EXCEPTION.getCode())
|
||||||
|
.setErrorDetail(baseResultBean.getErrorMsg())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<M> modelBeanList = baseResultBean.getResultList();
|
||||||
|
insertBusiList(transform(modelBeanList));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务数据修改同步
|
||||||
|
* @param syncData
|
||||||
|
*/
|
||||||
|
public void busiUpdateSync(MdmSyncData syncData){
|
||||||
|
BaseResultBean<M> baseResultBean =
|
||||||
|
baseMdmBusiModelCloud.findByIds(syncData.getSyncDataId().toArray(new Long[syncData.getSyncDataId().size()]));
|
||||||
|
if (!baseResultBean.isSuccess()) {
|
||||||
|
throw ImppExceptionBuilder.newInstance()
|
||||||
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.MDM.getCode())
|
||||||
|
.setErrorCode(ImppExceptionEnum.CLOUD_CALL_EXCEPTION.getCode())
|
||||||
|
.setErrorDetail(baseResultBean.getErrorMsg())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<M> modelBeanList = baseResultBean.getResultList();
|
||||||
|
updateBusiList(transform(modelBeanList));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务数据删除同步
|
||||||
|
* @param syncData
|
||||||
|
*/
|
||||||
|
public void busiDeleteSync(MdmSyncData syncData){
|
||||||
|
deleteBusiList(syncData.getSyncDataId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型转换
|
||||||
|
* @param syncDataList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract List<T> transform(List<M> syncDataList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增业务数据
|
||||||
|
* @param beanList
|
||||||
|
*/
|
||||||
|
public abstract void insertBusiList(List<T> beanList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改业务数据
|
||||||
|
* @param beanList
|
||||||
|
*/
|
||||||
|
public abstract void updateBusiList(List<T> beanList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除业务数据
|
||||||
|
* @param idList
|
||||||
|
*/
|
||||||
|
public abstract void deleteBusiList(List<Long> idList);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
package cn.estsh.i3plus.core.apiservice.serviceimpl.mdm;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysToolService;
|
||||||
|
import cn.estsh.i3plus.core.apiservice.serviceimpl.base.BaseBusiSyncMdmDataService;
|
||||||
|
import cn.estsh.i3plus.icloud.mdm.sdk.base.IBaseMdmBusiExtdCloud;
|
||||||
|
import cn.estsh.i3plus.icloud.mdm.sdk.base.IBaseMdmBusiModelCloud;
|
||||||
|
import cn.estsh.i3plus.pojo.mdm.model.core.MdmGearCoreBusiModel;
|
||||||
|
import cn.estsh.i3plus.pojo.platform.bean.SysTool;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description :
|
||||||
|
* @Reference :
|
||||||
|
* @Author : yunhao
|
||||||
|
* @CreateDate : 2020-06-03 15:08
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
@Component
|
||||||
|
public class SysToolSyncDataService extends BaseBusiSyncMdmDataService<SysTool, MdmGearCoreBusiModel> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysToolService sysToolService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public SysToolSyncDataService(IBaseMdmBusiExtdCloud baseMdmBusiExtdCloud, IBaseMdmBusiModelCloud<MdmGearCoreBusiModel> baseMdmBusiModelCloud) {
|
||||||
|
super(baseMdmBusiExtdCloud, baseMdmBusiModelCloud);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysTool> transform(List<MdmGearCoreBusiModel> syncDataList) {
|
||||||
|
return syncDataList.stream().map(gearCoreBusiModel -> {
|
||||||
|
SysTool sysTool = new SysTool();
|
||||||
|
if (gearCoreBusiModel != null && gearCoreBusiModel.getBusi() != null && gearCoreBusiModel.getMaster() != null) {
|
||||||
|
sysTool.setName(gearCoreBusiModel.getMaster().getName());
|
||||||
|
sysTool.setToolIp(gearCoreBusiModel.getMaster().getGearModel());
|
||||||
|
sysTool.setToolDescription(gearCoreBusiModel.getBusi().getCoreNum());
|
||||||
|
}
|
||||||
|
return sysTool;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertBusiList(List<SysTool> beanList) {
|
||||||
|
for (SysTool sysTool : beanList) {
|
||||||
|
sysToolService.insertSysTool(sysTool);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateBusiList(List<SysTool> beanList) {
|
||||||
|
for (SysTool sysTool : beanList) {
|
||||||
|
sysToolService.updateSysTool(sysTool);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteBusiList(List<Long> id) {
|
||||||
|
sysToolService.deleteSysToolByIds(id.toArray(new Long[id.size()]));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue