opt: 修改首页单据处理数量,单据明细实时自动审核;
This commit is contained in:
@@ -1,31 +1,29 @@
|
||||
/*
|
||||
* Copyright 2019-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.nl.common.utils;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.time.temporal.Temporal;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author: liaojinlong
|
||||
* @date: 2020/6/11 16:28
|
||||
* 时间工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class DateUtil {
|
||||
|
||||
public class DateUtil extends org.apache.commons.lang3.time.DateUtils {
|
||||
public static String YYYY = "yyyy";
|
||||
public static String YYYY_MM = "yyyy-MM";
|
||||
public static String YYYY_MM_DD = "yyyy-MM-dd";
|
||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
public static String YYYYMMDDHHMMSS_MS = "yyyyMMddHHmmssSS";
|
||||
public static final DateTimeFormatter DFY_MD_HMS = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
public static final DateTimeFormatter DFY_MD = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
@@ -35,18 +33,18 @@ public class DateUtil {
|
||||
* @param localDateTime /
|
||||
* @return /
|
||||
*/
|
||||
public static Long getDate(LocalDateTime localDateTime) {
|
||||
public static Long getTimeStamp(LocalDateTime localDateTime) {
|
||||
return localDateTime.atZone(ZoneId.systemDefault()).toEpochSecond();
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间戳转LocalDateTime
|
||||
*
|
||||
* @param Date /
|
||||
* @param timeStamp /
|
||||
* @return /
|
||||
*/
|
||||
public static LocalDateTime fromDate(Long Date) {
|
||||
return LocalDateTime.ofEpochSecond(Date, 0, OffsetDateTime.now().getOffset());
|
||||
public static LocalDateTime fromTimeStamp(Long timeStamp) {
|
||||
return LocalDateTime.ofEpochSecond(timeStamp, 0, OffsetDateTime.now().getOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +69,6 @@ public class DateUtil {
|
||||
return toDate(localDate.atTime(LocalTime.now(ZoneId.systemDefault())));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Date转 LocalDateTime
|
||||
* Jdk8 后 不推荐使用 {@link Date} Date
|
||||
@@ -156,4 +153,329 @@ public class DateUtil {
|
||||
public static LocalDateTime parseLocalDateTimeFormatyMdHms(String localDateTime) {
|
||||
return LocalDateTime.from(DFY_MD_HMS.parse(localDateTime));
|
||||
}
|
||||
|
||||
private static String[] parsePatterns = {
|
||||
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取当前Date型日期
|
||||
*
|
||||
* @return Date() 当前日期
|
||||
*/
|
||||
public static Date getNowDate() {
|
||||
return new Date();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期, 默认格式为yyyy-MM-dd
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public static String getDate() {
|
||||
return dateTimeNow(YYYY_MM_DD);
|
||||
}
|
||||
|
||||
public static final String getTime() {
|
||||
return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
|
||||
}
|
||||
|
||||
public static final String dateTimeNowMs() {
|
||||
return dateTimeNow(YYYYMMDDHHMMSS_MS);
|
||||
}
|
||||
|
||||
public static final String dateTimeNow(final String format) {
|
||||
return parseDateToStr(format, new Date());
|
||||
}
|
||||
|
||||
public static final String dateTime(final Date date) {
|
||||
return parseDateToStr(YYYY_MM_DD, date);
|
||||
}
|
||||
|
||||
public static final String parseDateToStr(final String format, final Date date) {
|
||||
return new SimpleDateFormat(format).format(date);
|
||||
}
|
||||
|
||||
public static final Date dateTime(final String format, final String ts) {
|
||||
try {
|
||||
return new SimpleDateFormat(format).parse(ts);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期路径 即年/月/日 如2018/08/08
|
||||
*/
|
||||
public static final String datePath() {
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, "yyyy/MM/dd");
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期路径 即年/月/日 如20180808
|
||||
*/
|
||||
public static final String dateTime() {
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, "yyyyMMdd");
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期路径 即年/月/日 如20180808
|
||||
*/
|
||||
public static final String year() {
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, "yyyy");
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期型字符串转化为日期 格式
|
||||
*/
|
||||
public static Date parseDates(Object str, Integer index) {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return parseDate(str.toString(), parsePatterns[index]);
|
||||
} catch (ParseException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务器启动时间
|
||||
*/
|
||||
public static Date getServerStartDate() {
|
||||
long time = ManagementFactory.getRuntimeMXBean().getStartTime();
|
||||
return new Date(time);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两个时间差
|
||||
*/
|
||||
public static String getDatePoor(Date endDate, Date nowDate) {
|
||||
long nd = 1000 * 24 * 60 * 60;
|
||||
long nh = 1000 * 60 * 60;
|
||||
long nm = 1000 * 60;
|
||||
// long ns = 1000;
|
||||
// 获得两个时间的毫秒时间差异
|
||||
long diff = endDate.getTime() - nowDate.getTime();
|
||||
// 计算差多少天
|
||||
long day = diff / nd;
|
||||
// 计算差多少小时
|
||||
long hour = diff % nd / nh;
|
||||
// 计算差多少分钟
|
||||
long min = diff % nd % nh / nm;
|
||||
// 计算差多少秒//输出结果
|
||||
// long sec = diff % nd % nh % nm / ns;
|
||||
return day + "天" + hour + "小时" + min + "分钟";
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两个时间差
|
||||
*/
|
||||
public static long getDatePoorHour(Date endDate, Date nowDate) {
|
||||
long nd = 1000 * 24 * 60 * 60;
|
||||
long nh = 1000 * 60 * 60;
|
||||
long nm = 1000 * 60;
|
||||
// long ns = 1000;
|
||||
// 获得两个时间的毫秒时间差异
|
||||
long diff = endDate.getTime() - nowDate.getTime();
|
||||
// 计算差多少小时
|
||||
long hour = diff % nd / nh;
|
||||
return hour;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据年月日计算月份差
|
||||
*/
|
||||
public static long getDateDiff(Date startDateTime, Date endDateTime) {
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String startDate = df.format(startDateTime);
|
||||
String endTime = df.format(endDateTime);
|
||||
Temporal temporalNowDate = LocalDate.parse(startDate);
|
||||
Temporal temporalStartTime = LocalDate.parse(endTime);
|
||||
return ChronoUnit.MONTHS.between(temporalStartTime, temporalNowDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据一个时间段计算另一段时间段的结束时间
|
||||
*/
|
||||
public static Date getDateEndFromInterval(String startDateTime, String endDateTime, Date startTime) {
|
||||
// 开始和结束时间
|
||||
LocalDateTime intervalStart = LocalDateTime.parse(startDateTime, DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"));
|
||||
LocalDateTime intervalEnd = LocalDateTime.parse(endDateTime, DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"));
|
||||
// 计算时间间隔时长
|
||||
long intervalDuration = ChronoUnit.SECONDS.between(intervalStart, intervalEnd);
|
||||
long interval2EndEpochSecond = startTime.toInstant().getEpochSecond() + intervalDuration;
|
||||
return Date.from(Instant.ofEpochSecond(interval2EndEpochSecond));
|
||||
}
|
||||
|
||||
|
||||
public static Date getTime(Date date, int amount) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
//把日期往后增加一天.整数往后推,负数往前移动(1:表示明天、-1:表示昨天,0:表示今天)
|
||||
calendar.add(Calendar.DATE, amount);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取过去第几天的日期
|
||||
*
|
||||
* @param past
|
||||
* @return
|
||||
*/
|
||||
public static String getPastDate(Date date, int past) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - past);
|
||||
Date today = calendar.getTime();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String result = format.format(today);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Date getSameDayHourTime(Date date, int hourOfDay) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
public static String getStringDateMonthByDate(Date date) {
|
||||
return parseDateToStr(YYYY_MM, date);
|
||||
}
|
||||
|
||||
public static Date getDateMonthByString(String date) {
|
||||
return dateTime(YYYY_MM, date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 年、月 获取对应的月份 的 天数
|
||||
*/
|
||||
public static int getDaysByYearMonth(Date date) {
|
||||
Calendar a = Calendar.getInstance();
|
||||
a.setTime(date);
|
||||
a.set(Calendar.DATE, 1);
|
||||
a.roll(Calendar.DATE, -1);
|
||||
int maxDate = a.get(Calendar.DATE);
|
||||
return maxDate;
|
||||
}
|
||||
|
||||
public static int getDaysByYearMonth2(int year, int month) {
|
||||
Calendar a = Calendar.getInstance();
|
||||
a.set(Calendar.YEAR, year);
|
||||
a.set(Calendar.MONTH, month - 1);
|
||||
a.set(Calendar.DATE, 1);
|
||||
a.roll(Calendar.DATE, -1);
|
||||
int maxDate = a.get(Calendar.DATE);
|
||||
return maxDate;
|
||||
}
|
||||
|
||||
//获取年月yyyymm
|
||||
public static String getYearMonth() {
|
||||
String months = "";
|
||||
Calendar a = Calendar.getInstance();
|
||||
Integer year = a.get(Calendar.YEAR);
|
||||
Integer month = a.get(Calendar.MONTH);
|
||||
if (month <= 9) {
|
||||
months = "0" + month;
|
||||
} else {
|
||||
months = month.toString();
|
||||
}
|
||||
return year + months;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转换为Date
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public static Date toDateByStartTime(String startTime)
|
||||
throws ParseException {
|
||||
startTime = startTime + " 00:00:00";
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date beginDate = dateFormat.parse(startTime);
|
||||
return beginDate;
|
||||
}
|
||||
|
||||
public static Date toDateByEndTime(String endTime)
|
||||
throws ParseException {
|
||||
endTime = endTime + " 23:59:59";
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date endDate = dateFormat.parse(endTime);
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public static String getDate(Date date)
|
||||
throws ParseException {
|
||||
LocalDate time = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
String format = time.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
return format;
|
||||
}
|
||||
|
||||
public static String getDate1(Date date)
|
||||
throws ParseException {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
LocalDate time = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
String format = time.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
return format;
|
||||
}
|
||||
|
||||
public static String getDateStringYmd(String date) {
|
||||
if (StringUtils.isBlank(date)) {
|
||||
return "";
|
||||
}
|
||||
if (!date.contains(":")) {
|
||||
return date;
|
||||
}
|
||||
if (date.contains(".")) {
|
||||
int currentYear = cn.hutool.core.date.DateUtil.thisYear(); // 假设默认使用2023年份
|
||||
String[] dateParts = date.split("\\.");
|
||||
String month = dateParts[1];
|
||||
String day = dateParts[2];
|
||||
// 将提取的部分拼接成标准的日期格式"yyyy-MM-dd"
|
||||
return currentYear + "-" + month + "-" + day;
|
||||
}
|
||||
LocalDateTime dateTime = LocalDateTime.parse(date.replace("/", "-"), DFY_MD_HMS);
|
||||
return dateTime.format(DFY_MD);
|
||||
}
|
||||
|
||||
public static Date getDate(String date)
|
||||
throws ParseException {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date format = dateFormat.parse(date);
|
||||
return format;
|
||||
}
|
||||
|
||||
public static Date getDates(String date,String dateParseFormat )
|
||||
throws ParseException {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(dateParseFormat);
|
||||
Date format = dateFormat.parse(date);
|
||||
return format;
|
||||
}
|
||||
|
||||
|
||||
public static Date dateByEndTime(Date endTime)
|
||||
throws ParseException {
|
||||
String date = getDate(endTime);
|
||||
date = date + " 23:59:59";
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date endDate = dateFormat.parse(date);
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public static Date dateByStartTime(Date startTime)
|
||||
throws ParseException {
|
||||
String date = getDate(startTime);
|
||||
date = date + " 00:00:00";
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date endDate = dateFormat.parse(date);
|
||||
return endDate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ public class EasOutInBillDetail extends Model<EasOutInBillDetail> {
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date xgsj;
|
||||
private String xgsj;
|
||||
|
||||
/**
|
||||
* 获取主键值
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
@@ -289,7 +290,13 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
|
||||
//比较insertEasBills与existingIds的修改时间进行按需更新
|
||||
for (EasOutInBillDetail entity : insertEasBills) {
|
||||
EasOutInBillDetail existing = existingIds.stream()
|
||||
.filter(e -> e.getFlid().equals(entity.getFlid()) && e.getXgsj().after(entity.getXgsj()))
|
||||
.filter(e -> {
|
||||
try {
|
||||
return e.getFlid().equals(entity.getFlid()) && org.nl.common.utils.DateUtil.getDate(e.getXgsj()).after(org.nl.common.utils.DateUtil.getDate(entity.getXgsj()));
|
||||
} catch (ParseException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
})
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (existing != null) {
|
||||
|
||||
Reference in New Issue
Block a user