From c376b2ed79feec9612a1c35ad7d370ea15508bc8 Mon Sep 17 00:00:00 2001
From: yxFwq <1>
Date: 星期四, 28 十一月 2024 22:52:38 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/task/handler/WrkMastCrnHandler.java | 3
src/main/java/com/zy/asrs/utils/TimeCalculatorUtils.java | 358 +++++++++++++++++++++++++++++++++++++++++++++++++++
src/main/java/com/zy/asrs/task/WrkMastSplitTwinInItScheduler.java | 21 ++
src/main/java/com/zy/asrs/task/WrkMastCrnScheduler.java | 3
4 files changed, 382 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/zy/asrs/task/WrkMastCrnScheduler.java b/src/main/java/com/zy/asrs/task/WrkMastCrnScheduler.java
index a5d7d58..b07a3c9 100644
--- a/src/main/java/com/zy/asrs/task/WrkMastCrnScheduler.java
+++ b/src/main/java/com/zy/asrs/task/WrkMastCrnScheduler.java
@@ -115,7 +115,8 @@
if (Cools.isEmpty(rgvOneSign)){
continue;
}
- if (rgvOneSign.getRgvOneSign()>=2){
+ int wrkCount = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("sta_no", wrkMast.getStaNo()).eq("wrk_sts",12L));
+ if (wrkCount+rgvOneSign.getRgvOneSign()>=3){
continue;
}
// BasDevp basDevp = basDevpService.selectById(wrkMast.getStaNoBying());
diff --git a/src/main/java/com/zy/asrs/task/WrkMastSplitTwinInItScheduler.java b/src/main/java/com/zy/asrs/task/WrkMastSplitTwinInItScheduler.java
index 09f9124..1775708 100644
--- a/src/main/java/com/zy/asrs/task/WrkMastSplitTwinInItScheduler.java
+++ b/src/main/java/com/zy/asrs/task/WrkMastSplitTwinInItScheduler.java
@@ -5,6 +5,7 @@
import com.zy.asrs.entity.*;
import com.zy.asrs.service.*;
import com.zy.asrs.task.handler.WrkMastSplitTwinInItHandler;
+import com.zy.asrs.utils.TimeCalculatorUtils;
import com.zy.common.model.enums.CrnStnType;
import com.zy.common.model.enums.WrkMastExecuteType;
import org.slf4j.Logger;
@@ -14,6 +15,7 @@
import org.springframework.stereotype.Component;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
/**
@@ -99,6 +101,7 @@
case 2:
List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 12L).eq("crn_no", crnNo));
if (wrkMasts.size()==1){
+ Integer wrkNo = wrkMasts.get(0).getWrkNo();
wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 11L).eq("crn_no", crnNo));
if (wrkMasts.isEmpty()){
if (basCrnp.getCrnStatusOne() != 20) {//鍫嗗灈鏈哄伐浣�1鏈夌墿寰呬綔涓�
@@ -119,7 +122,8 @@
if (Cools.isEmpty(rgvOneSign)){
continue;
}
- if (rgvOneSign.getRgvOneSign()>=2){
+ int wrkCount = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("sta_no", wrkMast.getStaNo()).eq("wrk_sts",12L));
+ if (wrkCount+rgvOneSign.getRgvOneSign()>=3){
continue;
}
// int wrkCount = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 110).gt("sta_no", 309).lt("sta_no", 314).gt("wrk_sts",11L));
@@ -147,6 +151,21 @@
// }
break;
}
+ WrkMastSplitTwin wrkMastSplitTwin1 = wrkMastSplitTwinService.selectOne(new EntityWrapper<WrkMastSplitTwin>().eq("wrk_no", wrkNo));
+ if (!Cools.isEmpty(wrkMastSplitTwin1)){
+ long differenceInSeconds = TimeCalculatorUtils.differenceInSeconds(wrkMastSplitTwin1.getUpdateTime(), new Date());
+ if (differenceInSeconds>180){
+ if (basCrnp.getCrnStatusOne() != 20) {//鍫嗗灈鏈哄伐浣�1鏈夌墿寰呬綔涓�
+ break;
+ }
+ if (wrkMastSplitTwin.getWrkSts()!=2){
+ break;
+ }
+ wrkMastSplitTwinInItHandler.start(wrkMastSplitTwin);
+ break;
+ }
+ }
+
// signBigTurn++;
// if (signBigTurn > 2){
// signBigTurn = 0;
diff --git a/src/main/java/com/zy/asrs/task/handler/WrkMastCrnHandler.java b/src/main/java/com/zy/asrs/task/handler/WrkMastCrnHandler.java
index fea38fd..b02d099 100644
--- a/src/main/java/com/zy/asrs/task/handler/WrkMastCrnHandler.java
+++ b/src/main/java/com/zy/asrs/task/handler/WrkMastCrnHandler.java
@@ -127,7 +127,8 @@
if (Cools.isEmpty(rgvOneSign)){
return FAIL;
}
- if (rgvOneSign.getRgvOneSign()>=2){
+ int wrkCount = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("sta_no", wrkMastOther.getStaNo()).eq("wrk_sts",12L));
+ if (wrkCount+rgvOneSign.getRgvOneSign()>=3){
return FAIL;
}
}
diff --git a/src/main/java/com/zy/asrs/utils/TimeCalculatorUtils.java b/src/main/java/com/zy/asrs/utils/TimeCalculatorUtils.java
new file mode 100644
index 0000000..69fd538
--- /dev/null
+++ b/src/main/java/com/zy/asrs/utils/TimeCalculatorUtils.java
@@ -0,0 +1,358 @@
+package com.zy.asrs.utils;
+
+import java.time.DayOfWeek;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.temporal.ChronoUnit;
+import java.time.temporal.TemporalAdjusters;
+import java.time.temporal.WeekFields;
+import java.util.*;
+
+public class TimeCalculatorUtils {
+
+
+
+ //鑾峰彇涓冨ぉ鍓嶇殑鏃ユ湡锛堟棩鏈熷ぉ鏁板噺涓冿級
+ public static Date timeFrontSevenYesterday(Date date){
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ calendar.add(Calendar.DAY_OF_MONTH, -7);
+ return calendar.getTime();
+ }
+
+ //鑾峰彇涓冨ぉ鍚庣殑鏃ユ湡锛堟棩鏈熷ぉ鏁板姞涓冿級
+ public static Date timeAfterSevenYesterday(Date date){
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ calendar.add(Calendar.DAY_OF_MONTH, 7);
+ return calendar.getTime();
+ }
+
+ //鑾峰彇鐩稿樊n澶╃殑鏃ユ湡锛堟棩鏈熷ぉ鏁板姞N锛�
+ public static Date timeYesterdayN(Date date,int day){
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ calendar.add(Calendar.DAY_OF_MONTH, day);
+ return calendar.getTime();
+ }
+
+ //鑾峰彇骞存湀鏃�
+ public static String timeYestMonthDay(Date date){
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+
+ int year = calendar.get(Calendar.YEAR);
+ int month = calendar.get(Calendar.MONTH) + 1; // 鏈堜唤浠�0寮�濮嬶紝闇�瑕佸姞1
+ int day = calendar.get(Calendar.DAY_OF_MONTH);
+ return year+"骞�"+month+"鏈�"+day+"鏃�";
+ }
+
+ //鑾峰彇骞�
+ public static int timeYest(Date date){
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+
+ return calendar.get(Calendar.YEAR);
+ }
+
+ //鑾峰彇鏈�
+ public static int timeMonth(Date date){
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+
+ return calendar.get(Calendar.MONTH) + 1;
+ }
+
+ //鑾峰彇鏃�
+ public static int timeDay(Date date){
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+
+ return calendar.get(Calendar.DAY_OF_MONTH);
+ }
+ //鑾峰彇骞村樊寮�
+ public static int DifferenceYest(Date startDay,Date endDay){
+ int startYest = timeYest(startDay);
+ int endYest = timeYest(endDay);
+ return endYest-startYest;
+ }
+ //鑾峰彇鏈堝樊寮�
+ public static int DifferenceMonth(Date startDay,Date endDay){
+ int startMonth = timeMonth(startDay);
+ int endMonth = timeMonth(endDay);
+ return endMonth-startMonth;
+ }
+ //鑾峰彇澶╁樊寮�
+ public static int DifferenceDayInt(Date startDay,Date endDay){
+ return DifferenceDayLong(startDay,endDay).intValue();
+ }
+ //鑾峰彇澶╁樊寮�
+ public static Long DifferenceDayLong(Date startDay,Date endDay){
+
+ LocalDate a = LocalDate.of(timeYest(startDay), timeMonth(startDay), timeDay(startDay));
+ LocalDate b = LocalDate.of(timeYest(endDay), timeMonth(endDay), timeDay(endDay));
+
+ return ChronoUnit.DAYS.between(a, b)+1;
+ }
+ //鑾峰彇澶╁樊寮�
+ public static Double DifferenceDayMorningAfternoon(Date startDay,Date endDay,int startTime,int endTime){
+ double between = DifferenceDayLong(startDay, endDay).doubleValue();
+ if (startTime==2){
+ between = between-0.5;
+ }
+ if (endTime == 1){
+ between = between-0.5;
+ }
+ return between;
+ }
+
+ //鑾峰彇姣宸紓
+ public static Long differenceInMilliseconds(Date startDay, Date endDay) {
+ if (startDay == null || endDay == null) {
+ throw new IllegalArgumentException("Dates cannot be null");
+ }
+
+ // 鑾峰彇姣宸紓
+ return endDay.getTime() - startDay.getTime();
+ }
+
+ //鑾风宸紓
+ public static long differenceInSeconds(Date startDay, Date endDay) {
+ if (startDay == null || endDay == null) {
+ throw new IllegalArgumentException("Dates cannot be null");
+ }
+
+ // 鑾峰彇姣宸紓锛屽苟杞崲涓虹
+ long millisecondsDifference = endDay.getTime() - startDay.getTime();
+ return millisecondsDifference / 1000;
+ }
+
+ public static boolean CompareData(Date startDay,Date endDay){
+
+ // 灏嗘棩鏈熷瓧绗︿覆瑙f瀽涓篖ocalDate瀵硅薄
+ LocalDate a = LocalDate.of(timeYest(startDay), timeMonth(startDay), timeDay(startDay));
+ LocalDate b = LocalDate.of(timeYest(endDay), timeMonth(endDay), timeDay(endDay));
+
+ // 姣旇緝鏃ユ湡
+ if (a.isAfter(b)) {
+ return false;
+ } else if (a.isBefore(b)) {
+ return true;
+ } else {
+ return true;
+ }
+ }
+
+ //java.time.LocalDate 杞崲涓� java.util.Date;
+ public static Date DateLocalDate(LocalDate localDate) {
+ return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ }
+
+ //鑾峰彇鐜板湪鏃ユ湡鏄綋鏈堢鍑犲懆
+ public static int WeeklyNowMonthDay(Date date) {
+// int day = timeDay(date);
+// if (day<7){
+// if (WeeklyNowMonth(WeeklyMonday(date))>2){
+// return 1;
+// }
+// }
+ return WeeklyNowMonth(WeeklyMonday(date));
+ }
+ public static int WeeklyNowMonth(Date date) {
+// LocalDate currentDate = LocalDate.now();
+ LocalDate currentDate = LocalDate.of(timeYest(date), timeMonth(date), timeDay(date));
+
+ WeekFields weekFields = WeekFields.of(Locale.getDefault());
+
+ int weekOfMonth = currentDate.get(weekFields.weekOfMonth());
+
+
+ return weekOfMonth;
+ }
+
+ //闄愬埗涓や釜鏃ユ湡鏄懆涓�鍜屽懆鏈� 宸ヤ綔鏃� 鍛ㄤ竴鍒板懆鍏�
+ public static void WeeklySix(Date date) {
+// LocalDate startDate = LocalDate.of(2022, 9, 5); // 鍋囪寮�濮嬫棩鏈熸槸2022骞�9鏈�5鏃ワ紝鍛ㄤ竴
+ LocalDate startDate = LocalDate.of(timeYest(date), timeMonth(date), timeDay(date));
+ System.out.println("褰撳墠鏃ユ湡 " + startDate + " 鍛�");
+
+ LocalDate endDate = startDate.plus(6, ChronoUnit.DAYS); // 缁撴潫鏃ユ湡鏄紑濮嬫棩鏈熷姞涓�6澶�
+ System.out.println("褰撳墠鏃ユ湡鍔犱笂6澶╂槸 " + endDate + " 鍛�");
+
+
+ // 濡傛灉寮�濮嬫棩鏈熶笉鏄懆涓�锛屽垯灏嗗畠璋冩暣鍒颁笅涓�涓懆涓�
+ if (startDate.getDayOfWeek() != DayOfWeek.MONDAY) {
+ startDate = startDate.with(TemporalAdjusters.next(DayOfWeek.MONDAY));
+ }
+
+ // 濡傛灉缁撴潫鏃ユ湡涓嶆槸鍛ㄦ湯锛堝嵆鍛ㄥ叚鎴栧懆鏃ワ級锛屽垯灏嗗畠璋冩暣鍒颁笅涓�涓懆鏈�
+ if (endDate.getDayOfWeek() != DayOfWeek.SATURDAY && endDate.getDayOfWeek() != DayOfWeek.SUNDAY) {
+ endDate = endDate.with(TemporalAdjusters.next(DayOfWeek.SATURDAY));
+ }
+
+ // 纭繚涓や釜鏃ユ湡涔嬮棿鐩搁殧涓冨ぉ
+ while (startDate.plus(7, ChronoUnit.DAYS).isBefore(endDate)) {
+ startDate = startDate.plus(7, ChronoUnit.DAYS);
+ }
+
+ System.out.println("寮�濮嬫棩鏈燂細" + startDate);
+ System.out.println("缁撴潫鏃ユ湡锛�" + endDate);
+ }
+
+ //闄愬埗涓や釜鏃ユ湡鏄懆涓�鍜屽懆鏈� 鍛ㄤ竴鍒板懆鏃�
+ public static List<Date> WeeklySeven(Date date) {
+// LocalDate startDate = LocalDate.of(2022, 9, 5); // 鍋囪寮�濮嬫棩鏈熸槸2022骞�9鏈�5鏃ワ紝鍛ㄤ竴
+ LocalDate startDate = LocalDate.of(timeYest(date), timeMonth(date), timeDay(date));
+// System.out.println("褰撳墠鏃ユ湡 " + startDate + " 鍛�");
+
+ LocalDate endDate = startDate.plus(6, ChronoUnit.DAYS); // 缁撴潫鏃ユ湡鏄紑濮嬫棩鏈熷姞涓�6澶�
+// System.out.println("褰撳墠鏃ユ湡鍔犱笂6澶╂槸 " + endDate + " 鍛�");
+
+ // 濡傛灉寮�濮嬫棩鏈熶笉鏄懆涓�锛屽垯灏嗗畠璋冩暣鍒颁笅涓�涓懆涓�
+ if (startDate.getDayOfWeek() != DayOfWeek.MONDAY) {
+ startDate = startDate.with(TemporalAdjusters.next(DayOfWeek.MONDAY));
+ }
+
+ // 濡傛灉缁撴潫鏃ユ湡涓嶆槸鍛ㄦ棩锛屽垯灏嗗畠璋冩暣鍒颁笅涓�涓懆鏃�
+ if (endDate.getDayOfWeek() != DayOfWeek.SUNDAY) {
+ endDate = endDate.with(TemporalAdjusters.next(DayOfWeek.SUNDAY));
+ }
+
+ // 纭繚涓や釜鏃ユ湡涔嬮棿鐩搁殧涓冨ぉ
+ while (startDate.plus(7, ChronoUnit.DAYS).isBefore(endDate)) {
+ startDate = startDate.plus(7, ChronoUnit.DAYS);
+ }
+
+ List<Date> dateList = new ArrayList<>();
+ dateList.add(DateLocalDate(startDate));
+ dateList.add(DateLocalDate(endDate));
+ return dateList;
+// System.out.println("寮�濮嬫棩鏈燂細" + startDate);
+// System.out.println("缁撴潫鏃ユ湡锛�" + endDate);
+ }
+
+ //鍒ゆ柇鏄笉鏄懆涓�
+ public static boolean WeeklyOneSign(Date date) {
+ LocalDate localDate = LocalDate.of(timeYest(date), timeMonth(date), timeDay(date));
+ // 鍒ゆ柇鏄笉鏄懆涓�
+ if (localDate.getDayOfWeek() != DayOfWeek.MONDAY) {
+ return false;
+ }
+ return true;
+ }
+
+ //鑾峰彇鏈懆鍛ㄤ竴
+ public static Date WeeklyMonday (Date date) {
+ LocalDate localDate = LocalDate.of(timeYest(date), timeMonth(date), timeDay(date));
+ // 涓嬪懆鍛ㄤ竴
+ localDate = localDate.with(TemporalAdjusters.next(DayOfWeek.MONDAY));
+
+ // 灏哃ocalDate杞崲涓篋ate
+ Date monday = DateLocalDate(localDate);
+
+ // 鍒欏皢瀹冭皟鏁村埌鏈懆鍛ㄤ竴
+ return timeFrontSevenYesterday(monday);
+ }
+
+ //鑾峰彇褰撳墠鏃ユ湡鎵�鍦ㄧ殑鍛ㄤ竴鍙婂懆鏃ユ椂闂�
+ public static List<Date> WeeklyMondayAndSundayNow(Date date) {
+ Date nowMonday = WeeklyMonday(date);
+ return WeeklySeven(nowMonday);
+ }
+
+ //鑾峰彇褰撳墠鏃ユ湡涓婁竴鍛ㄥ懆涓�鍙婂懆鏃ユ椂闂�
+ public static List<Date> WeeklyMondayAndSundayFront(Date date) {
+ Date nowMonday = WeeklyMonday(date);
+ Date frontSevenYesterday = timeFrontSevenYesterday(nowMonday);
+ return WeeklySeven(frontSevenYesterday);
+ }
+
+ //鑾峰彇褰撳墠鏃ユ湡涓嬩竴鍛ㄥ懆涓�鍙婂懆鏃ユ椂闂�
+ public static List<Date> WeeklyMondayAndSundayAfter(Date date) {
+ Date nowMonday = WeeklyMonday(date);
+ Date afterSevenYesterday = timeAfterSevenYesterday(nowMonday);
+ return WeeklySeven(afterSevenYesterday);
+ }
+
+ //鑾峰彇鍛ㄤ竴鍒板懆鏈�
+ public static List<Date> WeeklyDays(Date date){
+ Date nowMonday = WeeklyMonday(date);
+ List<Date> dateList = new ArrayList<>();
+ dateList.add(nowMonday);
+ for (int i = 1; i<7 ; i++){
+ dateList.add(timeYesterdayN(nowMonday,i));
+ }
+ return dateList;
+ }
+
+ //鑾峰彇鍛ㄤ竴鍒板懆鏈�
+ public static List<Date> WeeklyListDays(List<Date> dates){
+ Date date = dates.get(0);
+ Date nowMonday = WeeklyMonday(date);
+ List<Date> dateList = new ArrayList<>();
+ dateList.add(nowMonday);
+ for (int i = 1; i<7 ; i++){
+ dateList.add(timeYesterdayN(nowMonday,i));
+ }
+ return dateList;
+ }
+
+ public static void main(String[] args) {
+ Date now = new Date();
+ int weeklyNowMonth = WeeklyNowMonthDay(now);
+ System.out.println("褰撳墠鏃ユ湡鏄 " + weeklyNowMonth + " 鍛�");
+
+ LocalDate startDate1 = LocalDate.of(2024, 2, 29);
+ int weeklyNowMonth1 = WeeklyNowMonthDay(DateLocalDate(startDate1));
+ System.out.println("褰撳墠鏃ユ湡鏄 " + weeklyNowMonth1 + " 鍛�");
+
+ LocalDate startDate2 = LocalDate.of(2024, 3, 5);
+ int weeklyNowMonth2 = WeeklyNowMonthDay(DateLocalDate(startDate2));
+ System.out.println("褰撳墠鏃ユ湡鏄 " + weeklyNowMonth2 + " 鍛�");
+
+ LocalDate startDate3 = LocalDate.of(2024, 3, 10);
+ int weeklyNowMonth3 = WeeklyNowMonthDay(DateLocalDate(startDate3));
+ System.out.println("褰撳墠鏃ユ湡鏄 " + weeklyNowMonth3 + " 鍛�");
+
+ LocalDate startDate4 = LocalDate.of(2024, 3, 31);
+ int weeklyNowMonth4 = WeeklyNowMonthDay(DateLocalDate(startDate4));
+ System.out.println("褰撳墠鏃ユ湡鏄 " + weeklyNowMonth4 + " 鍛�");
+
+ LocalDate startDate5 = LocalDate.of(2024, 4, 1);
+ int weeklyNowMonth5 = WeeklyNowMonthDay(DateLocalDate(startDate5));
+ System.out.println("褰撳墠鏃ユ湡鏄 " + weeklyNowMonth5 + " 鍛�");
+
+ LocalDate startDate6 = LocalDate.of(2024, 4, 7);
+ int weeklyNowMonth6 = WeeklyNowMonthDay(DateLocalDate(startDate6));
+ System.out.println("褰撳墠鏃ユ湡鏄 " + weeklyNowMonth6 + " 鍛�");
+ }
+
+// public static void main(String[] args) {
+// Date now = new Date();
+// //鏈懆
+// List<Date> dateList = WeeklyMondayAndSundayNow(now);
+// for (Date date : dateList){
+// System.out.println("------------------------------");
+// System.out.println(date);
+// }
+// //涓婂懆
+// List<Date> dateList1 = WeeklyMondayAndSundayFront(now);
+// for (Date date : dateList1){
+// System.out.println("------------------------------");
+// System.out.println(date);
+// }
+// //涓嬪懆
+// List<Date> dateList2 = WeeklyMondayAndSundayAfter(now);
+// for (Date date : dateList2){
+// System.out.println("------------------------------");
+// System.out.println(date);
+// }
+// //鍛�
+// List<Date> dateList3 = WeeklyDays(now);
+// for (Date date : dateList3){
+// System.out.println("------------------------------");
+// System.out.println(date);
+// }
+// }
+
+}
--
Gitblit v1.9.1