Compare commits
No commits in common. "f02e04016d8797e94643d76dddd1f161ed1b3fb5" and "6982e6f538b7fab8c696fa8aa5a8d81640e77683" have entirely different histories.
f02e04016d
...
6982e6f538
|
|
@ -390,8 +390,8 @@ public class DeviceController extends ControllerBase {
|
||||||
}
|
}
|
||||||
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
|
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
|
||||||
try {
|
try {
|
||||||
LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
LocalDate date = LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
device.setShipmentDate(dto.getShipmentDate());
|
device.setShipmentDate(DateTimeUtil.asSystemDate(date));
|
||||||
} 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(dto.getStartWarrantyDate());
|
device.setStartWarrantyDate(DateTimeUtil.asSystemDate(date));
|
||||||
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(d.getShipmentDate());
|
dto.setShipmentDate(DateTimeUtil.format(d.getShipmentDate(), "yyyy-MM-dd"));
|
||||||
dto.setStartWarrantyDate(d.getStartWarrantyDate());
|
dto.setStartWarrantyDate(DateTimeUtil.format(d.getStartWarrantyDate(), "yyyy-MM-dd"));
|
||||||
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.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
LocalDate date = LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
device.setShipmentDate(dto.getShipmentDate());
|
device.setShipmentDate(DateTimeUtil.asSystemDate(date));
|
||||||
} 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(dto.getStartWarrantyDate());
|
device.setStartWarrantyDate(DateTimeUtil.asSystemDate(date));
|
||||||
if (StrUtil.isBlank(dto.getWarrantyMonth())) {
|
if (StrUtil.isBlank(dto.getWarrantyMonth())) {
|
||||||
sb.append("质保期不能为空;");
|
sb.append("质保期不能为空;");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
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-设备信息
|
||||||
|
|
@ -39,14 +37,12 @@ public class CmrDeviceResultVO {
|
||||||
/**
|
/**
|
||||||
* 发货日期
|
* 发货日期
|
||||||
*/
|
*/
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
private LocalDate LastCarDevliverDate__c;
|
||||||
private OffsetDateTime LastCarDevliverDate__c;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 质保开始日期
|
* 质保开始日期
|
||||||
*/
|
*/
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
private LocalDate WarrantyStartDate__c;
|
||||||
private OffsetDateTime WarrantyStartDate__c;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 质保期(月)
|
* 质保期(月)
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,11 @@ 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;
|
||||||
|
|
@ -30,7 +27,6 @@ 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;
|
||||||
|
|
||||||
|
|
@ -56,9 +52,6 @@ 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);
|
||||||
|
|
@ -149,7 +142,6 @@ 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("跳过没有产品线或设备类型的设备");
|
||||||
|
|
@ -195,30 +187,9 @@ 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());
|
||||||
if (Objects.nonNull(u.getLastCarDevliverDate__c())) {
|
ent.setShipmentDate(u.getLastCarDevliverDate__c());
|
||||||
ent.setShipmentDate(DateTimeUtil.asSystemDateTime(u.getLastCarDevliverDate__c()).format(DateTimeFormatter.ISO_LOCAL_DATE));
|
ent.setStartWarrantyDate(u.getWarrantyStartDate__c());
|
||||||
} 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,7 +2,10 @@ package com.nflg.mobilebroken.common.util;
|
||||||
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
|
||||||
import java.time.*;
|
import java.time.LocalDate;
|
||||||
|
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;
|
||||||
|
|
@ -50,14 +53,6 @@ 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.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
LocalDate date = LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
device.setShipmentDate(dto.getShipmentDate());
|
device.setShipmentDate(DateTimeUtil.asSystemDate(date));
|
||||||
} 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(dto.getStartWarrantyDate());
|
device.setStartWarrantyDate(DateTimeUtil.asSystemDate(date));
|
||||||
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(d.getShipmentDate());
|
dto.setShipmentDate(DateTimeUtil.format(d.getShipmentDate(), "yyyy-MM-dd"));
|
||||||
dto.setStartWarrantyDate(d.getStartWarrantyDate());
|
dto.setStartWarrantyDate(DateTimeUtil.format(d.getStartWarrantyDate(), "yyyy-MM-dd"));
|
||||||
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.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
LocalDate date = LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
device.setShipmentDate(dto.getShipmentDate());
|
device.setShipmentDate(DateTimeUtil.asSystemDate(date));
|
||||||
} 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(dto.getStartWarrantyDate());
|
device.setStartWarrantyDate(DateTimeUtil.asSystemDate(date));
|
||||||
if (StrUtil.isBlank(dto.getWarrantyMonth())) {
|
if (StrUtil.isBlank(dto.getWarrantyMonth())) {
|
||||||
sb.append("质保期不能为空;");
|
sb.append("质保期不能为空;");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
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-设备信息
|
||||||
|
|
@ -39,14 +37,12 @@ public class CmrDeviceResultVO {
|
||||||
/**
|
/**
|
||||||
* 发货日期
|
* 发货日期
|
||||||
*/
|
*/
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
private LocalDate LastCarDevliverDate__c;
|
||||||
private OffsetDateTime LastCarDevliverDate__c;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 质保开始日期
|
* 质保开始日期
|
||||||
*/
|
*/
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
private LocalDate WarrantyStartDate__c;
|
||||||
private OffsetDateTime WarrantyStartDate__c;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 质保期(月)
|
* 质保期(月)
|
||||||
|
|
|
||||||
|
|
@ -7,21 +7,16 @@ 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;
|
||||||
|
|
@ -30,7 +25,6 @@ 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;
|
||||||
|
|
||||||
|
|
@ -56,9 +50,6 @@ 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);
|
||||||
|
|
@ -157,7 +148,6 @@ 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("跳过没有产品线或设备类型的设备");
|
||||||
|
|
@ -166,7 +156,6 @@ 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)) {
|
||||||
|
|
@ -205,31 +194,9 @@ 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());
|
||||||
if (Objects.nonNull(u.getLastCarDevliverDate__c())) {
|
ent.setShipmentDate(u.getLastCarDevliverDate__c());
|
||||||
ent.setShipmentDate(DateTimeUtil.asSystemDateTime(u.getLastCarDevliverDate__c()).format(DateTimeFormatter.ISO_LOCAL_DATE));
|
ent.setStartWarrantyDate(u.getWarrantyStartDate__c());
|
||||||
} 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,14 +124,11 @@ 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 data = JSONUtil.toJsonStr(dateParam);
|
String orderResult = httpUtils.doPost(getDeviceUrl, JSONUtil.toJsonStr(dateParam), token);
|
||||||
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,8 +1,6 @@
|
||||||
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;
|
||||||
|
|
@ -93,20 +91,17 @@ public class Device implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 发货日期
|
* 发货日期
|
||||||
*/
|
*/
|
||||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
private LocalDate shipmentDate;
|
||||||
private String shipmentDate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 质保状态-来自字典
|
* 质保状态-来自字典
|
||||||
*/
|
*/
|
||||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
|
||||||
private Integer warrantyState;
|
private Integer warrantyState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开始质保日期
|
* 开始质保日期
|
||||||
*/
|
*/
|
||||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
private LocalDate startWarrantyDate;
|
||||||
private String startWarrantyDate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 质保期(月)
|
* 质保期(月)
|
||||||
|
|
@ -161,6 +156,5 @@ public class Device implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 设备地址
|
* 设备地址
|
||||||
*/
|
*/
|
||||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
|
||||||
private String address;
|
private String address;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.nflg.mobilebroken.repository.entity;
|
package com.nflg.mobilebroken.repository.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
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;
|
||||||
|
|
@ -90,20 +92,17 @@ public class GongfuDevice implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 发货日期
|
* 发货日期
|
||||||
*/
|
*/
|
||||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
private LocalDate shipmentDate;
|
||||||
private String shipmentDate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 质保状态-来自字典
|
* 质保状态-来自字典
|
||||||
*/
|
*/
|
||||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
|
||||||
private Integer warrantyState;
|
private Integer warrantyState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开始质保日期
|
* 开始质保日期
|
||||||
*/
|
*/
|
||||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
private LocalDate startWarrantyDate;
|
||||||
private String startWarrantyDate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 质保期(月)
|
* 质保期(月)
|
||||||
|
|
@ -158,6 +157,5 @@ public class GongfuDevice implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 设备地址
|
* 设备地址
|
||||||
*/
|
*/
|
||||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
|
||||||
private String address;
|
private String address;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue