Merge branch 'develop' into feature/quotation
# Conflicts: # nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/Device.java # nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/GongfuDevice.java
This commit is contained in:
commit
b9830ab001
|
|
@ -390,8 +390,8 @@ public class DeviceController extends ControllerBase {
|
||||||
}
|
}
|
||||||
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
|
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
|
||||||
try {
|
try {
|
||||||
LocalDate date = LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
device.setShipmentDate(DateTimeUtil.asSystemDate(date));
|
device.setShipmentDate(dto.getShipmentDate());
|
||||||
} catch (DateTimeParseException e) {
|
} catch (DateTimeParseException e) {
|
||||||
sb.append("发货日期无效;");
|
sb.append("发货日期无效;");
|
||||||
}
|
}
|
||||||
|
|
@ -399,7 +399,7 @@ public class DeviceController extends ControllerBase {
|
||||||
if (StrUtil.isNotBlank(dto.getStartWarrantyDate())) {
|
if (StrUtil.isNotBlank(dto.getStartWarrantyDate())) {
|
||||||
try {
|
try {
|
||||||
LocalDate date = LocalDate.parse(dto.getStartWarrantyDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
LocalDate date = LocalDate.parse(dto.getStartWarrantyDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
device.setStartWarrantyDate(DateTimeUtil.asSystemDate(date));
|
device.setStartWarrantyDate(dto.getStartWarrantyDate());
|
||||||
if (StrUtil.isBlank(dto.getWarrantyMonth())) {
|
if (StrUtil.isBlank(dto.getWarrantyMonth())) {
|
||||||
sb.append("质保期不能为空;");
|
sb.append("质保期不能为空;");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -487,8 +487,8 @@ public class DeviceController extends ControllerBase {
|
||||||
dto.setAgentName(d.getAgentName());
|
dto.setAgentName(d.getAgentName());
|
||||||
dto.setAreaName(d.getAreaName());
|
dto.setAreaName(d.getAreaName());
|
||||||
dto.setAddress(d.getAddress());
|
dto.setAddress(d.getAddress());
|
||||||
dto.setShipmentDate(DateTimeUtil.format(d.getShipmentDate(), "yyyy-MM-dd"));
|
dto.setShipmentDate(d.getShipmentDate());
|
||||||
dto.setStartWarrantyDate(DateTimeUtil.format(d.getStartWarrantyDate(), "yyyy-MM-dd"));
|
dto.setStartWarrantyDate(d.getStartWarrantyDate());
|
||||||
if (Objects.nonNull(d.getWarrantyMonth())) {
|
if (Objects.nonNull(d.getWarrantyMonth())) {
|
||||||
dto.setWarrantyMonth(String.valueOf(d.getWarrantyMonth()));
|
dto.setWarrantyMonth(String.valueOf(d.getWarrantyMonth()));
|
||||||
}
|
}
|
||||||
|
|
@ -620,8 +620,8 @@ public class DeviceController extends ControllerBase {
|
||||||
}
|
}
|
||||||
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
|
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
|
||||||
try {
|
try {
|
||||||
LocalDate date = LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
device.setShipmentDate(DateTimeUtil.asSystemDate(date));
|
device.setShipmentDate(dto.getShipmentDate());
|
||||||
} catch (DateTimeParseException e) {
|
} catch (DateTimeParseException e) {
|
||||||
sb.append("发货日期无效;");
|
sb.append("发货日期无效;");
|
||||||
}
|
}
|
||||||
|
|
@ -631,7 +631,7 @@ public class DeviceController extends ControllerBase {
|
||||||
if (StrUtil.isNotBlank(dto.getStartWarrantyDate())) {
|
if (StrUtil.isNotBlank(dto.getStartWarrantyDate())) {
|
||||||
try {
|
try {
|
||||||
LocalDate date = LocalDate.parse(dto.getStartWarrantyDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
LocalDate date = LocalDate.parse(dto.getStartWarrantyDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
device.setStartWarrantyDate(DateTimeUtil.asSystemDate(date));
|
device.setStartWarrantyDate(dto.getStartWarrantyDate());
|
||||||
if (StrUtil.isBlank(dto.getWarrantyMonth())) {
|
if (StrUtil.isBlank(dto.getWarrantyMonth())) {
|
||||||
sb.append("质保期不能为空;");
|
sb.append("质保期不能为空;");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
package com.nflg.mobilebroken.admin.pojo.vo;
|
package com.nflg.mobilebroken.admin.pojo.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CRM-设备信息
|
* CRM-设备信息
|
||||||
|
|
@ -37,12 +39,14 @@ public class CmrDeviceResultVO {
|
||||||
/**
|
/**
|
||||||
* 发货日期
|
* 发货日期
|
||||||
*/
|
*/
|
||||||
private LocalDate LastCarDevliverDate__c;
|
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
||||||
|
private OffsetDateTime LastCarDevliverDate__c;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 质保开始日期
|
* 质保开始日期
|
||||||
*/
|
*/
|
||||||
private LocalDate WarrantyStartDate__c;
|
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
||||||
|
private OffsetDateTime WarrantyStartDate__c;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 质保期(月)
|
* 质保期(月)
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,14 @@ import com.nflg.mobilebroken.admin.pojo.vo.DeviceExcelVO;
|
||||||
import com.nflg.mobilebroken.common.constant.Constant;
|
import com.nflg.mobilebroken.common.constant.Constant;
|
||||||
import com.nflg.mobilebroken.common.constant.STATE;
|
import com.nflg.mobilebroken.common.constant.STATE;
|
||||||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||||
|
import com.nflg.mobilebroken.common.util.DateTimeUtil;
|
||||||
import com.nflg.mobilebroken.common.util.VUtils;
|
import com.nflg.mobilebroken.common.util.VUtils;
|
||||||
import com.nflg.mobilebroken.repository.entity.Device;
|
import com.nflg.mobilebroken.repository.entity.Device;
|
||||||
|
import com.nflg.mobilebroken.repository.entity.DictionaryItem;
|
||||||
import com.nflg.mobilebroken.repository.entity.GongfuDevice;
|
import com.nflg.mobilebroken.repository.entity.GongfuDevice;
|
||||||
import com.nflg.mobilebroken.repository.entity.TBaseCustomer;
|
import com.nflg.mobilebroken.repository.entity.TBaseCustomer;
|
||||||
import com.nflg.mobilebroken.repository.service.IDeviceService;
|
import com.nflg.mobilebroken.repository.service.IDeviceService;
|
||||||
|
import com.nflg.mobilebroken.repository.service.IDictionaryItemService;
|
||||||
import com.nflg.mobilebroken.repository.service.IGongfuDeviceService;
|
import com.nflg.mobilebroken.repository.service.IGongfuDeviceService;
|
||||||
import com.nflg.mobilebroken.repository.service.ITBaseCustomerService;
|
import com.nflg.mobilebroken.repository.service.ITBaseCustomerService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
@ -27,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
@ -52,6 +56,9 @@ public class AdminDeviceService {
|
||||||
@Resource
|
@Resource
|
||||||
private ITBaseCustomerService customerService;
|
private ITBaseCustomerService customerService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
IDictionaryItemService dictionaryItemService;
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void add(DeviceDTO deviceDTO) {
|
public void add(DeviceDTO deviceDTO) {
|
||||||
Device device = Convert.convert(Device.class, deviceDTO);
|
Device device = Convert.convert(Device.class, deviceDTO);
|
||||||
|
|
@ -142,6 +149,7 @@ public class AdminDeviceService {
|
||||||
|
|
||||||
List<TBaseCustomer> agents = customerService.lambdaQuery().select(TBaseCustomer::getAgencyCompanyCode, TBaseCustomer::getAgencyCompanyName).list();
|
List<TBaseCustomer> agents = customerService.lambdaQuery().select(TBaseCustomer::getAgencyCompanyCode, TBaseCustomer::getAgencyCompanyName).list();
|
||||||
Set<String> deviceNos = new HashSet<>();
|
Set<String> deviceNos = new HashSet<>();
|
||||||
|
List<DictionaryItem> warrantyStates = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DEVICE_WARRANTY_STATE);
|
||||||
crmDeviceList.forEach(u -> {
|
crmDeviceList.forEach(u -> {
|
||||||
if (StrUtil.isBlank(u.getProductLine__c()) || StrUtil.isBlank(u.getAssetProductLine3__c()) || StrUtil.isBlank(u.getAssetProductLine4__c())) {
|
if (StrUtil.isBlank(u.getProductLine__c()) || StrUtil.isBlank(u.getAssetProductLine3__c()) || StrUtil.isBlank(u.getAssetProductLine4__c())) {
|
||||||
log.info("跳过没有产品线或设备类型的设备");
|
log.info("跳过没有产品线或设备类型的设备");
|
||||||
|
|
@ -187,9 +195,30 @@ public class AdminDeviceService {
|
||||||
}
|
}
|
||||||
ent.setSourceFrom(DeviceSourceFromEnum.FROM_CRM.getSourceKey());
|
ent.setSourceFrom(DeviceSourceFromEnum.FROM_CRM.getSourceKey());
|
||||||
ent.setProductLine(u.getProductLine__c());
|
ent.setProductLine(u.getProductLine__c());
|
||||||
ent.setShipmentDate(u.getLastCarDevliverDate__c());
|
if (Objects.nonNull(u.getLastCarDevliverDate__c())) {
|
||||||
ent.setStartWarrantyDate(u.getWarrantyStartDate__c());
|
ent.setShipmentDate(DateTimeUtil.asSystemDateTime(u.getLastCarDevliverDate__c()).format(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||||
|
} else {
|
||||||
|
ent.setShipmentDate(null);
|
||||||
|
}
|
||||||
ent.setWarrantyMonth(u.getWarrantyPeriod1__c());
|
ent.setWarrantyMonth(u.getWarrantyPeriod1__c());
|
||||||
|
if (Objects.nonNull(u.getWarrantyStartDate__c())) {
|
||||||
|
if (Objects.isNull(ent.getWarrantyMonth())){
|
||||||
|
ent.setWarrantyMonth(0);
|
||||||
|
}
|
||||||
|
LocalDateTime warrantyStartDate=DateTimeUtil.asSystemDateTime(u.getWarrantyStartDate__c());
|
||||||
|
ent.setStartWarrantyDate(warrantyStartDate.format(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||||
|
LocalDateTime now=LocalDateTime.now();
|
||||||
|
if (now.isBefore(warrantyStartDate)){
|
||||||
|
ent.setWarrantyState(warrantyStates.stream().filter(s -> StrUtil.equals(s.getCode(), "NotStarted")).findFirst().get().getId());
|
||||||
|
}else if (now.isAfter(warrantyStartDate.plusMonths(ent.getWarrantyMonth()))){
|
||||||
|
ent.setWarrantyState(warrantyStates.stream().filter(s -> StrUtil.equals(s.getCode(), "OutsideWarranty")).findFirst().get().getId());
|
||||||
|
}else {
|
||||||
|
ent.setWarrantyState(warrantyStates.stream().filter(s -> StrUtil.equals(s.getCode(), "WithinWarranty")).findFirst().get().getId());
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
ent.setStartWarrantyDate(null);
|
||||||
|
ent.setWarrantyState(null);
|
||||||
|
}
|
||||||
if (Objects.nonNull(u.getAgent__r())) {
|
if (Objects.nonNull(u.getAgent__r())) {
|
||||||
TBaseCustomer customer = agents.stream()
|
TBaseCustomer customer = agents.stream()
|
||||||
.filter(agent -> agent.getAgencyCompanyCode().equals(u.getAgent__r().getId()))
|
.filter(agent -> agent.getAgencyCompanyCode().equals(u.getAgent__r().getId()))
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,7 @@ package com.nflg.mobilebroken.common.util;
|
||||||
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.*;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
@ -53,6 +50,14 @@ public class DateTimeUtil {
|
||||||
.toLocalDateTime();
|
.toLocalDateTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static LocalDateTime asSystemDateTime(OffsetDateTime datetime) {
|
||||||
|
if (Objects.isNull(datetime)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return datetime.atZoneSameInstant(ZoneId.systemDefault())
|
||||||
|
.toLocalDateTime();
|
||||||
|
}
|
||||||
|
|
||||||
public static LocalDate parse(String dateStr) {
|
public static LocalDate parse(String dateStr) {
|
||||||
return LocalDate.parse(dateStr, DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
|
return LocalDate.parse(dateStr, DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -393,8 +393,8 @@ public class DeviceController extends ControllerBase {
|
||||||
}
|
}
|
||||||
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
|
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
|
||||||
try {
|
try {
|
||||||
LocalDate date = LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
device.setShipmentDate(DateTimeUtil.asSystemDate(date));
|
device.setShipmentDate(dto.getShipmentDate());
|
||||||
} catch (DateTimeParseException e) {
|
} catch (DateTimeParseException e) {
|
||||||
sb.append("发货日期无效;");
|
sb.append("发货日期无效;");
|
||||||
}
|
}
|
||||||
|
|
@ -402,7 +402,7 @@ public class DeviceController extends ControllerBase {
|
||||||
if (StrUtil.isNotBlank(dto.getStartWarrantyDate())) {
|
if (StrUtil.isNotBlank(dto.getStartWarrantyDate())) {
|
||||||
try {
|
try {
|
||||||
LocalDate date = LocalDate.parse(dto.getStartWarrantyDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
LocalDate date = LocalDate.parse(dto.getStartWarrantyDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
device.setStartWarrantyDate(DateTimeUtil.asSystemDate(date));
|
device.setStartWarrantyDate(dto.getStartWarrantyDate());
|
||||||
if (StrUtil.isBlank(dto.getWarrantyMonth())) {
|
if (StrUtil.isBlank(dto.getWarrantyMonth())) {
|
||||||
sb.append("质保期不能为空;");
|
sb.append("质保期不能为空;");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -506,8 +506,8 @@ public class DeviceController extends ControllerBase {
|
||||||
dto.setCustomerName(d.getCustomerName());
|
dto.setCustomerName(d.getCustomerName());
|
||||||
dto.setAgentName(d.getAgentName());
|
dto.setAgentName(d.getAgentName());
|
||||||
dto.setAreaName(d.getAreaName());
|
dto.setAreaName(d.getAreaName());
|
||||||
dto.setShipmentDate(DateTimeUtil.format(d.getShipmentDate(), "yyyy-MM-dd"));
|
dto.setShipmentDate(d.getShipmentDate());
|
||||||
dto.setStartWarrantyDate(DateTimeUtil.format(d.getStartWarrantyDate(), "yyyy-MM-dd"));
|
dto.setStartWarrantyDate(d.getStartWarrantyDate());
|
||||||
if (Objects.nonNull(d.getWarrantyMonth())) {
|
if (Objects.nonNull(d.getWarrantyMonth())) {
|
||||||
dto.setWarrantyMonth(String.valueOf(d.getWarrantyMonth()));
|
dto.setWarrantyMonth(String.valueOf(d.getWarrantyMonth()));
|
||||||
}
|
}
|
||||||
|
|
@ -648,8 +648,8 @@ public class DeviceController extends ControllerBase {
|
||||||
}
|
}
|
||||||
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
|
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
|
||||||
try {
|
try {
|
||||||
LocalDate date = LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
device.setShipmentDate(DateTimeUtil.asSystemDate(date));
|
device.setShipmentDate(dto.getShipmentDate());
|
||||||
} catch (DateTimeParseException e) {
|
} catch (DateTimeParseException e) {
|
||||||
sb.append("发货日期无效;");
|
sb.append("发货日期无效;");
|
||||||
}
|
}
|
||||||
|
|
@ -659,7 +659,7 @@ public class DeviceController extends ControllerBase {
|
||||||
if (StrUtil.isNotBlank(dto.getStartWarrantyDate())) {
|
if (StrUtil.isNotBlank(dto.getStartWarrantyDate())) {
|
||||||
try {
|
try {
|
||||||
LocalDate date = LocalDate.parse(dto.getStartWarrantyDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
LocalDate date = LocalDate.parse(dto.getStartWarrantyDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
device.setStartWarrantyDate(DateTimeUtil.asSystemDate(date));
|
device.setStartWarrantyDate(dto.getStartWarrantyDate());
|
||||||
if (StrUtil.isBlank(dto.getWarrantyMonth())) {
|
if (StrUtil.isBlank(dto.getWarrantyMonth())) {
|
||||||
sb.append("质保期不能为空;");
|
sb.append("质保期不能为空;");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
package com.nflg.mobilebroken.gongfu.pojo.vo;
|
package com.nflg.mobilebroken.gongfu.pojo.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CRM-设备信息
|
* CRM-设备信息
|
||||||
|
|
@ -37,12 +39,14 @@ public class CmrDeviceResultVO {
|
||||||
/**
|
/**
|
||||||
* 发货日期
|
* 发货日期
|
||||||
*/
|
*/
|
||||||
private LocalDate LastCarDevliverDate__c;
|
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
||||||
|
private OffsetDateTime LastCarDevliverDate__c;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 质保开始日期
|
* 质保开始日期
|
||||||
*/
|
*/
|
||||||
private LocalDate WarrantyStartDate__c;
|
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
||||||
|
private OffsetDateTime WarrantyStartDate__c;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 质保期(月)
|
* 质保期(月)
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,21 @@ import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.nflg.mobilebroken.common.constant.Constant;
|
import com.nflg.mobilebroken.common.constant.Constant;
|
||||||
|
import com.nflg.mobilebroken.common.constant.STATE;
|
||||||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||||
|
import com.nflg.mobilebroken.common.util.DateTimeUtil;
|
||||||
|
import com.nflg.mobilebroken.common.util.VUtils;
|
||||||
import com.nflg.mobilebroken.gongfu.constant.Constant1;
|
import com.nflg.mobilebroken.gongfu.constant.Constant1;
|
||||||
import com.nflg.mobilebroken.gongfu.constant.DeviceSourceFromEnum;
|
import com.nflg.mobilebroken.gongfu.constant.DeviceSourceFromEnum;
|
||||||
import com.nflg.mobilebroken.gongfu.pojo.dto.DeviceDTO;
|
import com.nflg.mobilebroken.gongfu.pojo.dto.DeviceDTO;
|
||||||
import com.nflg.mobilebroken.gongfu.pojo.dto.SyncFromCrmDTO;
|
import com.nflg.mobilebroken.gongfu.pojo.dto.SyncFromCrmDTO;
|
||||||
import com.nflg.mobilebroken.gongfu.pojo.vo.CmrDeviceResultVO;
|
import com.nflg.mobilebroken.gongfu.pojo.vo.CmrDeviceResultVO;
|
||||||
import com.nflg.mobilebroken.repository.entity.Device;
|
import com.nflg.mobilebroken.repository.entity.Device;
|
||||||
|
import com.nflg.mobilebroken.repository.entity.DictionaryItem;
|
||||||
import com.nflg.mobilebroken.repository.entity.GongfuDevice;
|
import com.nflg.mobilebroken.repository.entity.GongfuDevice;
|
||||||
import com.nflg.mobilebroken.repository.entity.TBaseCustomer;
|
import com.nflg.mobilebroken.repository.entity.TBaseCustomer;
|
||||||
import com.nflg.mobilebroken.repository.service.IDeviceService;
|
import com.nflg.mobilebroken.repository.service.IDeviceService;
|
||||||
|
import com.nflg.mobilebroken.repository.service.IDictionaryItemService;
|
||||||
import com.nflg.mobilebroken.repository.service.IGongfuDeviceService;
|
import com.nflg.mobilebroken.repository.service.IGongfuDeviceService;
|
||||||
import com.nflg.mobilebroken.repository.service.ITBaseCustomerService;
|
import com.nflg.mobilebroken.repository.service.ITBaseCustomerService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
@ -25,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
@ -50,6 +56,9 @@ public class AdminDeviceService {
|
||||||
@Resource
|
@Resource
|
||||||
private ITBaseCustomerService customerService;
|
private ITBaseCustomerService customerService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
IDictionaryItemService dictionaryItemService;
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void add(DeviceDTO deviceDTO) {
|
public void add(DeviceDTO deviceDTO) {
|
||||||
GongfuDevice device = Convert.convert(GongfuDevice.class, deviceDTO);
|
GongfuDevice device = Convert.convert(GongfuDevice.class, deviceDTO);
|
||||||
|
|
@ -148,6 +157,7 @@ public class AdminDeviceService {
|
||||||
|
|
||||||
List<TBaseCustomer> agents = customerService.lambdaQuery().select(TBaseCustomer::getAgencyCompanyCode, TBaseCustomer::getAgencyCompanyName).list();
|
List<TBaseCustomer> agents = customerService.lambdaQuery().select(TBaseCustomer::getAgencyCompanyCode, TBaseCustomer::getAgencyCompanyName).list();
|
||||||
Set<String> deviceNos = new HashSet<>();
|
Set<String> deviceNos = new HashSet<>();
|
||||||
|
List<DictionaryItem> warrantyStates = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DEVICE_WARRANTY_STATE);
|
||||||
crmDeviceList.forEach(u -> {
|
crmDeviceList.forEach(u -> {
|
||||||
if (StrUtil.isBlank(u.getProductLine__c()) || StrUtil.isBlank(u.getAssetProductLine3__c()) || StrUtil.isBlank(u.getAssetProductLine4__c())) {
|
if (StrUtil.isBlank(u.getProductLine__c()) || StrUtil.isBlank(u.getAssetProductLine3__c()) || StrUtil.isBlank(u.getAssetProductLine4__c())) {
|
||||||
log.info("跳过没有产品线或设备类型的设备");
|
log.info("跳过没有产品线或设备类型的设备");
|
||||||
|
|
@ -156,6 +166,7 @@ public class AdminDeviceService {
|
||||||
} else if (StrUtil.isBlank(u.getProductLine5__c())) {
|
} else if (StrUtil.isBlank(u.getProductLine5__c())) {
|
||||||
log.error("设备机型为空,{}", JSONUtil.toJsonStr(u));
|
log.error("设备机型为空,{}", JSONUtil.toJsonStr(u));
|
||||||
} else {
|
} else {
|
||||||
|
log.debug("处理设备:"+u.getMachine_Number__c());
|
||||||
if (StrUtil.isNotBlank(u.getMachine_Number__c())) {
|
if (StrUtil.isNotBlank(u.getMachine_Number__c())) {
|
||||||
GongfuDevice ent = deviceMap.get(u.getId());
|
GongfuDevice ent = deviceMap.get(u.getId());
|
||||||
if (Objects.nonNull(ent)) {
|
if (Objects.nonNull(ent)) {
|
||||||
|
|
@ -194,9 +205,31 @@ public class AdminDeviceService {
|
||||||
ent.setSourceFrom(DeviceSourceFromEnum.FROM_CRM.getSourceKey());
|
ent.setSourceFrom(DeviceSourceFromEnum.FROM_CRM.getSourceKey());
|
||||||
ent.setProductLine(u.getProductLine__c());
|
ent.setProductLine(u.getProductLine__c());
|
||||||
Constant1.PRODUCT_LINE.add(u.getProductLine__c());
|
Constant1.PRODUCT_LINE.add(u.getProductLine__c());
|
||||||
ent.setShipmentDate(u.getLastCarDevliverDate__c());
|
if (Objects.nonNull(u.getLastCarDevliverDate__c())) {
|
||||||
ent.setStartWarrantyDate(u.getWarrantyStartDate__c());
|
ent.setShipmentDate(DateTimeUtil.asSystemDateTime(u.getLastCarDevliverDate__c()).format(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||||
|
} else {
|
||||||
|
ent.setShipmentDate(null);
|
||||||
|
}
|
||||||
ent.setWarrantyMonth(u.getWarrantyPeriod1__c());
|
ent.setWarrantyMonth(u.getWarrantyPeriod1__c());
|
||||||
|
if (Objects.nonNull(u.getWarrantyStartDate__c())) {
|
||||||
|
if (Objects.isNull(ent.getWarrantyMonth())){
|
||||||
|
ent.setWarrantyMonth(0);
|
||||||
|
}
|
||||||
|
LocalDateTime warrantyStartDate=DateTimeUtil.asSystemDateTime(u.getWarrantyStartDate__c());
|
||||||
|
ent.setStartWarrantyDate(warrantyStartDate.format(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||||
|
LocalDateTime now=LocalDateTime.now();
|
||||||
|
if (now.isBefore(warrantyStartDate)){
|
||||||
|
ent.setWarrantyState(warrantyStates.stream().filter(s -> StrUtil.equals(s.getCode(), "NotStarted")).findFirst().get().getId());
|
||||||
|
}else if (now.isAfter(warrantyStartDate.plusMonths(ent.getWarrantyMonth()))){
|
||||||
|
ent.setWarrantyState(warrantyStates.stream().filter(s -> StrUtil.equals(s.getCode(), "OutsideWarranty")).findFirst().get().getId());
|
||||||
|
}else {
|
||||||
|
ent.setWarrantyState(warrantyStates.stream().filter(s -> StrUtil.equals(s.getCode(), "WithinWarranty")).findFirst().get().getId());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ent.setStartWarrantyDate(null);
|
||||||
|
ent.setWarrantyState(null);
|
||||||
|
}
|
||||||
|
// VUtils.trueThrow(true).throwMessage(STATE.SystemErr,"测试");
|
||||||
if (Objects.nonNull(u.getAgent__r())) {
|
if (Objects.nonNull(u.getAgent__r())) {
|
||||||
TBaseCustomer customer = agents.stream()
|
TBaseCustomer customer = agents.stream()
|
||||||
.filter(agent -> agent.getAgencyCompanyCode().equals(u.getAgent__r().getId()))
|
.filter(agent -> agent.getAgencyCompanyCode().equals(u.getAgent__r().getId()))
|
||||||
|
|
|
||||||
|
|
@ -124,11 +124,14 @@ public class CrmService {
|
||||||
HttpUtils httpUtils = new HttpUtils();
|
HttpUtils httpUtils = new HttpUtils();
|
||||||
// reBody.put("CrLsDate", startDate);
|
// reBody.put("CrLsDate", startDate);
|
||||||
String token = StrUtil.join(" ", "Bearer", getToken());
|
String token = StrUtil.join(" ", "Bearer", getToken());
|
||||||
String orderResult = httpUtils.doPost(getDeviceUrl, JSONUtil.toJsonStr(dateParam), token);
|
String data = JSONUtil.toJsonStr(dateParam);
|
||||||
|
log.debug("请求地址:" + getDeviceUrl);
|
||||||
|
log.debug("请求参数:" + data);
|
||||||
|
String orderResult = httpUtils.doPost(getDeviceUrl, data, token);
|
||||||
|
log.debug("响应数据:" + orderResult);
|
||||||
JSONObject jsonObject = JSONUtil.parseObj(orderResult);
|
JSONObject jsonObject = JSONUtil.parseObj(orderResult);
|
||||||
String code = jsonObject.getStr("code");
|
String code = jsonObject.getStr("code");
|
||||||
if (Objects.equals(code, "0")) {
|
if (Objects.equals(code, "0")) {
|
||||||
log.debug("响应数据:" + orderResult);
|
|
||||||
String dataResult = jsonObject.getStr("jsonData");
|
String dataResult = jsonObject.getStr("jsonData");
|
||||||
return JSONUtil.toList(dataResult, CmrDeviceResultVO.class);
|
return JSONUtil.toList(dataResult, CmrDeviceResultVO.class);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
package com.nflg.mobilebroken.repository.entity;
|
package com.nflg.mobilebroken.repository.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -91,17 +92,20 @@ public class Device implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 发货日期
|
* 发货日期
|
||||||
*/
|
*/
|
||||||
private LocalDate shipmentDate;
|
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||||
|
private String shipmentDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 质保状态-来自字典
|
* 质保状态-来自字典
|
||||||
*/
|
*/
|
||||||
|
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||||
private Long warrantyState;
|
private Long warrantyState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开始质保日期
|
* 开始质保日期
|
||||||
*/
|
*/
|
||||||
private LocalDate startWarrantyDate;
|
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||||
|
private String startWarrantyDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 质保期(月)
|
* 质保期(月)
|
||||||
|
|
@ -156,5 +160,6 @@ public class Device implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 设备地址
|
* 设备地址
|
||||||
*/
|
*/
|
||||||
|
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||||
private String address;
|
private String address;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
package com.nflg.mobilebroken.repository.entity;
|
package com.nflg.mobilebroken.repository.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
@ -92,17 +90,20 @@ public class GongfuDevice implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 发货日期
|
* 发货日期
|
||||||
*/
|
*/
|
||||||
private LocalDate shipmentDate;
|
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||||
|
private String shipmentDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 质保状态-来自字典
|
* 质保状态-来自字典
|
||||||
*/
|
*/
|
||||||
|
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||||
private Long warrantyState;
|
private Long warrantyState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开始质保日期
|
* 开始质保日期
|
||||||
*/
|
*/
|
||||||
private LocalDate startWarrantyDate;
|
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||||
|
private String startWarrantyDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 质保期(月)
|
* 质保期(月)
|
||||||
|
|
@ -157,5 +158,6 @@ public class GongfuDevice implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 设备地址
|
* 设备地址
|
||||||
*/
|
*/
|
||||||
|
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||||
private String address;
|
private String address;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue