fix: 修复因存储的是UTC时间导致设备信息和用户信息的时间存储不正确的问题
This commit is contained in:
parent
afabf64e39
commit
91dbceb80f
|
|
@ -159,6 +159,7 @@ public class AppUserController extends ControllerBase {
|
||||||
@ApiMark(moduleName = "代理商管理", apiName = "更新代理商账号")
|
@ApiMark(moduleName = "代理商管理", apiName = "更新代理商账号")
|
||||||
public ApiResult<Void> updateAppUser(@Valid @RequestBody AppUserUpdateRequest request) throws MessagingException {
|
public ApiResult<Void> updateAppUser(@Valid @RequestBody AppUserUpdateRequest request) throws MessagingException {
|
||||||
AppUser user=appUserService.getById(request.getId());
|
AppUser user=appUserService.getById(request.getId());
|
||||||
|
user.setExpireTime(user.getExpireTime().plusDays(1));
|
||||||
if (user.getIsPrimary()){
|
if (user.getIsPrimary()){
|
||||||
updatePrimaryAppUser(user,request);
|
updatePrimaryAppUser(user,request);
|
||||||
}else {
|
}else {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import lombok.Data;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备管理编辑参数
|
* 设备管理编辑参数
|
||||||
|
|
@ -88,6 +88,13 @@ public class DeviceDTO {
|
||||||
@NotNull(message = "发货日期 不能为空")
|
@NotNull(message = "发货日期 不能为空")
|
||||||
private LocalDate shipmentDate;
|
private LocalDate shipmentDate;
|
||||||
|
|
||||||
|
public LocalDate getShipmentDate() {
|
||||||
|
if (Objects.isNull(shipmentDate)){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return shipmentDate.plusDays(1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 质保状态-来自字典
|
* 质保状态-来自字典
|
||||||
*/
|
*/
|
||||||
|
|
@ -100,6 +107,13 @@ public class DeviceDTO {
|
||||||
@NotNull(message = "开始质保日期不能为空")
|
@NotNull(message = "开始质保日期不能为空")
|
||||||
private LocalDate startWarrantyDate;
|
private LocalDate startWarrantyDate;
|
||||||
|
|
||||||
|
public LocalDate getStartWarrantyDate() {
|
||||||
|
if (Objects.isNull(startWarrantyDate)){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return startWarrantyDate.plusDays(1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 质保期(月)
|
* 质保期(月)
|
||||||
*/
|
*/
|
||||||
|
|
@ -121,25 +135,25 @@ public class DeviceDTO {
|
||||||
*/
|
*/
|
||||||
private Integer sourceFrom= DeviceSourceFromEnum.MANUAL_ADD.getSourceKey();
|
private Integer sourceFrom= DeviceSourceFromEnum.MANUAL_ADD.getSourceKey();
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 创建人
|
// * 创建人
|
||||||
*/
|
// */
|
||||||
private String createBy;
|
// private String createBy;
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 创建时间
|
// * 创建时间
|
||||||
*/
|
// */
|
||||||
private LocalDateTime createTime;
|
// private LocalDateTime createTime;
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 最后更新人
|
// * 最后更新人
|
||||||
*/
|
// */
|
||||||
private String updateBy;
|
// private String updateBy;
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 最后更新时间
|
// * 最后更新时间
|
||||||
*/
|
// */
|
||||||
private LocalDateTime updateTime;
|
// private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,8 @@ public class AdminDeviceService {
|
||||||
device.setSourceFrom(DeviceSourceFromEnum.MANUAL_ADD.getSourceKey());
|
device.setSourceFrom(DeviceSourceFromEnum.MANUAL_ADD.getSourceKey());
|
||||||
device.setCreateBy(AdminUserUtil.getUserName());
|
device.setCreateBy(AdminUserUtil.getUserName());
|
||||||
device.setCreateTime(LocalDateTime.now());
|
device.setCreateTime(LocalDateTime.now());
|
||||||
device.setUpdateBy(AdminUserUtil.getUserName());
|
// device.setUpdateBy(AdminUserUtil.getUserName());
|
||||||
device.setUpdateTime(LocalDateTime.now());
|
// device.setUpdateTime(LocalDateTime.now());
|
||||||
deviceService.save(device);
|
deviceService.save(device);
|
||||||
//将设备类型放入-设备类型表维护客户质量管理人
|
//将设备类型放入-设备类型表维护客户质量管理人
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,12 @@ 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.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZoneOffset;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class DateTimeUtil {
|
public class DateTimeUtil {
|
||||||
|
|
||||||
|
|
@ -12,4 +16,22 @@ public class DateTimeUtil {
|
||||||
public static String format(LocalDateTime dateTime){
|
public static String format(LocalDateTime dateTime){
|
||||||
return dateTime.format(FORMATTER);
|
return dateTime.format(FORMATTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static LocalDate asSystemDate(LocalDate date){
|
||||||
|
if (Objects.isNull(date)){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return date.atStartOfDay(ZoneOffset.UTC)
|
||||||
|
.withZoneSameInstant(ZoneId.systemDefault())
|
||||||
|
.toLocalDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LocalDateTime asSystemDateTime(LocalDateTime datetime){
|
||||||
|
if (Objects.isNull(datetime)){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return datetime.atZone(ZoneOffset.UTC)
|
||||||
|
.withZoneSameInstant(ZoneId.systemDefault())
|
||||||
|
.toLocalDateTime();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||||
.setUpdateBy(AdminUserUtil.getUserName())
|
.setUpdateBy(AdminUserUtil.getUserName())
|
||||||
.setUpdateTime(LocalDateTime.now())
|
.setUpdateTime(LocalDateTime.now())
|
||||||
.setState(UserState.ToBeActivated.getState())
|
.setState(UserState.ToBeActivated.getState())
|
||||||
.setExpireTime(LocalDateTime.of(LocalDateTime.now().getYear(), 12, 31, 8, 0, 0).toLocalDate());
|
.setExpireTime(LocalDate.of(LocalDateTime.now().getYear() + 1, 1, 1));
|
||||||
updateById(user);
|
updateById(user);
|
||||||
}else {
|
}else {
|
||||||
user = new AppUser()
|
user = new AppUser()
|
||||||
|
|
@ -189,7 +189,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||||
.setCreateBy(AdminUserUtil.getUserName())
|
.setCreateBy(AdminUserUtil.getUserName())
|
||||||
.setCreateTime(LocalDateTime.now())
|
.setCreateTime(LocalDateTime.now())
|
||||||
.setState(UserState.ToBeActivated.getState())
|
.setState(UserState.ToBeActivated.getState())
|
||||||
.setExpireTime(LocalDateTime.of(LocalDateTime.now().getYear(), 12, 31, 8, 0, 0).toLocalDate());
|
.setExpireTime(LocalDate.of(LocalDateTime.now().getYear() + 1, 1, 1));
|
||||||
save(user);
|
save(user);
|
||||||
}
|
}
|
||||||
return user;
|
return user;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue