feat: 从CRM同步设备信息逻辑调整
同步接口添加了设备状态字段,所以表中设备编号允许重复了,表还添加了来源id字段,用于更新数据
This commit is contained in:
parent
a0f4b92bd1
commit
3f89429512
|
|
@ -23,6 +23,7 @@ public class CmrDeviceResultVO {
|
|||
//客户
|
||||
private String Account;
|
||||
|
||||
private Integer CfsStatus__c;
|
||||
|
||||
|
||||
private String Id;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,26 +122,24 @@ public class AdminDeviceService {
|
|||
if (CollUtil.isEmpty(crmDeviceList)) {
|
||||
return;
|
||||
}
|
||||
Set<String> crmDeviceNos = crmDeviceList.stream().map(u -> u.getMachine_Number__c()).collect(Collectors.toSet());
|
||||
Set<String> crmDeviceIds = crmDeviceList.stream().map(CmrDeviceResultVO::getId).collect(Collectors.toSet());
|
||||
|
||||
List<Device> deviceList = deviceService.lambdaQuery().in(Device::getDeviceNo, crmDeviceNos).list();
|
||||
Map<String, Device> deviceMap = deviceList.stream().collect(Collectors.toMap(Device::getDeviceNo, device -> device));
|
||||
List<Device> deviceList = deviceService.lambdaQuery().eq(Device::getSourceFrom, DeviceSourceFromEnum.FROM_CRM.getSourceKey()).in(Device::getSourceId, crmDeviceIds).list();
|
||||
Map<String, Device> deviceMap = deviceList.stream().collect(Collectors.toMap(Device::getSourceId, device -> device));
|
||||
|
||||
crmDeviceList.forEach(u -> {
|
||||
if (StrUtil.isNotBlank(u.getMachine_Number__c())) {
|
||||
Device ent = deviceMap.get(u.getMachine_Number__c());
|
||||
Device ent = deviceMap.get(u.getId());
|
||||
if (Objects.nonNull(ent)) {
|
||||
ent = deviceMap.get(u.getMachine_Number__c());
|
||||
ent.setUpdateBy("crm");
|
||||
ent.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
} else {
|
||||
ent = new Device();
|
||||
ent.setUpdateBy("crm");
|
||||
ent.setUpdateTime(LocalDateTime.now());
|
||||
ent.setSourceId(u.getId());
|
||||
ent.setCreateBy("crm");
|
||||
ent.setCreateTime(LocalDateTime.now());
|
||||
}
|
||||
ent.setDeviceState(u.getCfsStatus__c());
|
||||
ent.setDeviceNo(u.getMachine_Number__c());
|
||||
ent.setDeviceType(u.getAssetProductLine3__c());
|
||||
ent.setDeviceTypeSub(u.getAssetProductLine4__c());
|
||||
|
|
@ -154,7 +152,6 @@ public class AdminDeviceService {
|
|||
|
||||
ent.setSourceFrom(DeviceSourceFromEnum.FROM_CRM.getSourceKey());
|
||||
ent.setCustomerId(0);
|
||||
ent.setDeviceState(0);
|
||||
result.add(ent);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@ package com.nflg.mobilebroken.repository.entity;
|
|||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备
|
||||
|
|
@ -117,6 +118,11 @@ public class Device implements Serializable {
|
|||
*/
|
||||
private Integer sourceFrom;
|
||||
|
||||
/**
|
||||
* 数据来源id
|
||||
*/
|
||||
private String sourceId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue