Compare commits

..

No commits in common. "f02e04016d8797e94643d76dddd1f161ed1b3fb5" and "6982e6f538b7fab8c696fa8aa5a8d81640e77683" have entirely different histories.

10 changed files with 37 additions and 123 deletions

View File

@ -390,8 +390,8 @@ public class DeviceController extends ControllerBase {
}
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
try {
LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
device.setShipmentDate(dto.getShipmentDate());
LocalDate date = LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
device.setShipmentDate(DateTimeUtil.asSystemDate(date));
} catch (DateTimeParseException e) {
sb.append("发货日期无效;");
}
@ -399,7 +399,7 @@ public class DeviceController extends ControllerBase {
if (StrUtil.isNotBlank(dto.getStartWarrantyDate())) {
try {
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())) {
sb.append("质保期不能为空;");
} else {
@ -487,8 +487,8 @@ public class DeviceController extends ControllerBase {
dto.setAgentName(d.getAgentName());
dto.setAreaName(d.getAreaName());
dto.setAddress(d.getAddress());
dto.setShipmentDate(d.getShipmentDate());
dto.setStartWarrantyDate(d.getStartWarrantyDate());
dto.setShipmentDate(DateTimeUtil.format(d.getShipmentDate(), "yyyy-MM-dd"));
dto.setStartWarrantyDate(DateTimeUtil.format(d.getStartWarrantyDate(), "yyyy-MM-dd"));
if (Objects.nonNull(d.getWarrantyMonth())) {
dto.setWarrantyMonth(String.valueOf(d.getWarrantyMonth()));
}
@ -620,8 +620,8 @@ public class DeviceController extends ControllerBase {
}
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
try {
LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
device.setShipmentDate(dto.getShipmentDate());
LocalDate date = LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
device.setShipmentDate(DateTimeUtil.asSystemDate(date));
} catch (DateTimeParseException e) {
sb.append("发货日期无效;");
}
@ -631,7 +631,7 @@ public class DeviceController extends ControllerBase {
if (StrUtil.isNotBlank(dto.getStartWarrantyDate())) {
try {
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())) {
sb.append("质保期不能为空;");
} else {

View File

@ -1,10 +1,8 @@
package com.nflg.mobilebroken.admin.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDate;
import java.time.OffsetDateTime;
/**
* CRM-设备信息
@ -39,14 +37,12 @@ public class CmrDeviceResultVO {
/**
* 发货日期
*/
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
private OffsetDateTime LastCarDevliverDate__c;
private LocalDate LastCarDevliverDate__c;
/**
* 质保开始日期
*/
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
private OffsetDateTime WarrantyStartDate__c;
private LocalDate WarrantyStartDate__c;
/**
* 质保期

View File

@ -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.STATE;
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.repository.entity.Device;
import com.nflg.mobilebroken.repository.entity.DictionaryItem;
import com.nflg.mobilebroken.repository.entity.GongfuDevice;
import com.nflg.mobilebroken.repository.entity.TBaseCustomer;
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.ITBaseCustomerService;
import lombok.extern.slf4j.Slf4j;
@ -30,7 +27,6 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -56,9 +52,6 @@ public class AdminDeviceService {
@Resource
private ITBaseCustomerService customerService;
@Resource
IDictionaryItemService dictionaryItemService;
@Transactional(rollbackFor = Exception.class)
public void add(DeviceDTO 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();
Set<String> deviceNos = new HashSet<>();
List<DictionaryItem> warrantyStates = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DEVICE_WARRANTY_STATE);
crmDeviceList.forEach(u -> {
if (StrUtil.isBlank(u.getProductLine__c()) || StrUtil.isBlank(u.getAssetProductLine3__c()) || StrUtil.isBlank(u.getAssetProductLine4__c())) {
log.info("跳过没有产品线或设备类型的设备");
@ -195,30 +187,9 @@ public class AdminDeviceService {
}
ent.setSourceFrom(DeviceSourceFromEnum.FROM_CRM.getSourceKey());
ent.setProductLine(u.getProductLine__c());
if (Objects.nonNull(u.getLastCarDevliverDate__c())) {
ent.setShipmentDate(DateTimeUtil.asSystemDateTime(u.getLastCarDevliverDate__c()).format(DateTimeFormatter.ISO_LOCAL_DATE));
} else {
ent.setShipmentDate(null);
}
ent.setShipmentDate(u.getLastCarDevliverDate__c());
ent.setStartWarrantyDate(u.getWarrantyStartDate__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())) {
TBaseCustomer customer = agents.stream()
.filter(agent -> agent.getAgencyCompanyCode().equals(u.getAgent__r().getId()))

View File

@ -2,7 +2,10 @@ package com.nflg.mobilebroken.common.util;
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.temporal.ChronoUnit;
import java.util.Objects;
@ -50,14 +53,6 @@ public class DateTimeUtil {
.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) {
return LocalDate.parse(dateStr, DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
}

View File

@ -393,8 +393,8 @@ public class DeviceController extends ControllerBase {
}
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
try {
LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
device.setShipmentDate(dto.getShipmentDate());
LocalDate date = LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
device.setShipmentDate(DateTimeUtil.asSystemDate(date));
} catch (DateTimeParseException e) {
sb.append("发货日期无效;");
}
@ -402,7 +402,7 @@ public class DeviceController extends ControllerBase {
if (StrUtil.isNotBlank(dto.getStartWarrantyDate())) {
try {
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())) {
sb.append("质保期不能为空;");
} else {
@ -506,8 +506,8 @@ public class DeviceController extends ControllerBase {
dto.setCustomerName(d.getCustomerName());
dto.setAgentName(d.getAgentName());
dto.setAreaName(d.getAreaName());
dto.setShipmentDate(d.getShipmentDate());
dto.setStartWarrantyDate(d.getStartWarrantyDate());
dto.setShipmentDate(DateTimeUtil.format(d.getShipmentDate(), "yyyy-MM-dd"));
dto.setStartWarrantyDate(DateTimeUtil.format(d.getStartWarrantyDate(), "yyyy-MM-dd"));
if (Objects.nonNull(d.getWarrantyMonth())) {
dto.setWarrantyMonth(String.valueOf(d.getWarrantyMonth()));
}
@ -648,8 +648,8 @@ public class DeviceController extends ControllerBase {
}
if (StrUtil.isNotBlank(dto.getShipmentDate())) {
try {
LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
device.setShipmentDate(dto.getShipmentDate());
LocalDate date = LocalDate.parse(dto.getShipmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
device.setShipmentDate(DateTimeUtil.asSystemDate(date));
} catch (DateTimeParseException e) {
sb.append("发货日期无效;");
}
@ -659,7 +659,7 @@ public class DeviceController extends ControllerBase {
if (StrUtil.isNotBlank(dto.getStartWarrantyDate())) {
try {
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())) {
sb.append("质保期不能为空;");
} else {

View File

@ -1,10 +1,8 @@
package com.nflg.mobilebroken.gongfu.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDate;
import java.time.OffsetDateTime;
/**
* CRM-设备信息
@ -39,14 +37,12 @@ public class CmrDeviceResultVO {
/**
* 发货日期
*/
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
private OffsetDateTime LastCarDevliverDate__c;
private LocalDate LastCarDevliverDate__c;
/**
* 质保开始日期
*/
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
private OffsetDateTime WarrantyStartDate__c;
private LocalDate WarrantyStartDate__c;
/**
* 质保期

View File

@ -7,21 +7,16 @@ import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.google.common.collect.ImmutableList;
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.DateTimeUtil;
import com.nflg.mobilebroken.common.util.VUtils;
import com.nflg.mobilebroken.gongfu.constant.Constant1;
import com.nflg.mobilebroken.gongfu.constant.DeviceSourceFromEnum;
import com.nflg.mobilebroken.gongfu.pojo.dto.DeviceDTO;
import com.nflg.mobilebroken.gongfu.pojo.dto.SyncFromCrmDTO;
import com.nflg.mobilebroken.gongfu.pojo.vo.CmrDeviceResultVO;
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.TBaseCustomer;
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.ITBaseCustomerService;
import lombok.extern.slf4j.Slf4j;
@ -30,7 +25,6 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -56,9 +50,6 @@ public class AdminDeviceService {
@Resource
private ITBaseCustomerService customerService;
@Resource
IDictionaryItemService dictionaryItemService;
@Transactional(rollbackFor = Exception.class)
public void add(DeviceDTO 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();
Set<String> deviceNos = new HashSet<>();
List<DictionaryItem> warrantyStates = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DEVICE_WARRANTY_STATE);
crmDeviceList.forEach(u -> {
if (StrUtil.isBlank(u.getProductLine__c()) || StrUtil.isBlank(u.getAssetProductLine3__c()) || StrUtil.isBlank(u.getAssetProductLine4__c())) {
log.info("跳过没有产品线或设备类型的设备");
@ -166,7 +156,6 @@ public class AdminDeviceService {
} else if (StrUtil.isBlank(u.getProductLine5__c())) {
log.error("设备机型为空,{}", JSONUtil.toJsonStr(u));
} else {
log.debug("处理设备:"+u.getMachine_Number__c());
if (StrUtil.isNotBlank(u.getMachine_Number__c())) {
GongfuDevice ent = deviceMap.get(u.getId());
if (Objects.nonNull(ent)) {
@ -205,31 +194,9 @@ public class AdminDeviceService {
ent.setSourceFrom(DeviceSourceFromEnum.FROM_CRM.getSourceKey());
ent.setProductLine(u.getProductLine__c());
Constant1.PRODUCT_LINE.add(u.getProductLine__c());
if (Objects.nonNull(u.getLastCarDevliverDate__c())) {
ent.setShipmentDate(DateTimeUtil.asSystemDateTime(u.getLastCarDevliverDate__c()).format(DateTimeFormatter.ISO_LOCAL_DATE));
} else {
ent.setShipmentDate(null);
}
ent.setShipmentDate(u.getLastCarDevliverDate__c());
ent.setStartWarrantyDate(u.getWarrantyStartDate__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())) {
TBaseCustomer customer = agents.stream()
.filter(agent -> agent.getAgencyCompanyCode().equals(u.getAgent__r().getId()))

View File

@ -124,14 +124,11 @@ public class CrmService {
HttpUtils httpUtils = new HttpUtils();
// reBody.put("CrLsDate", startDate);
String token = StrUtil.join(" ", "Bearer", getToken());
String data = JSONUtil.toJsonStr(dateParam);
log.debug("请求地址:" + getDeviceUrl);
log.debug("请求参数:" + data);
String orderResult = httpUtils.doPost(getDeviceUrl, data, token);
log.debug("响应数据:" + orderResult);
String orderResult = httpUtils.doPost(getDeviceUrl, JSONUtil.toJsonStr(dateParam), token);
JSONObject jsonObject = JSONUtil.parseObj(orderResult);
String code = jsonObject.getStr("code");
if (Objects.equals(code, "0")) {
log.debug("响应数据:" + orderResult);
String dataResult = jsonObject.getStr("jsonData");
return JSONUtil.toList(dataResult, CmrDeviceResultVO.class);
}

View File

@ -1,8 +1,6 @@
package com.nflg.mobilebroken.repository.entity;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;
@ -93,20 +91,17 @@ public class Device implements Serializable {
/**
* 发货日期
*/
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String shipmentDate;
private LocalDate shipmentDate;
/**
* 质保状态-来自字典
*/
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private Integer warrantyState;
/**
* 开始质保日期
*/
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String startWarrantyDate;
private LocalDate startWarrantyDate;
/**
* 质保期
@ -161,6 +156,5 @@ public class Device implements Serializable {
/**
* 设备地址
*/
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String address;
}

View File

@ -1,6 +1,8 @@
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.Setter;
import lombok.experimental.Accessors;
@ -90,20 +92,17 @@ public class GongfuDevice implements Serializable {
/**
* 发货日期
*/
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String shipmentDate;
private LocalDate shipmentDate;
/**
* 质保状态-来自字典
*/
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private Integer warrantyState;
/**
* 开始质保日期
*/
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String startWarrantyDate;
private LocalDate startWarrantyDate;
/**
* 质保期
@ -158,6 +157,5 @@ public class GongfuDevice implements Serializable {
/**
* 设备地址
*/
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String address;
}