|
|
@@ -17,6 +17,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.net.URI;
|
|
|
+import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
@@ -131,7 +132,32 @@ public class SendNoticeTask {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private Short checkNoticeWaitStaus(Date delivery, Integer stock) {
|
|
|
+ /**
|
|
|
+ * 可发货状态判断逻辑
|
|
|
+ * <pre>
|
|
|
+ * 1.判断当前是否属于同一个年份
|
|
|
+ * 1.1.属于同一年
|
|
|
+ * 1.1.1.物料备料提前期为-1
|
|
|
+ * 1.1.1.1.如果交货期为当月或之前月份,可以发货
|
|
|
+ * 1.1.1.2.如果交货期为下月
|
|
|
+ * 1.1.1.2.1.如果当前日期大于25,可以发货
|
|
|
+ * 1.1.1.2.2.如果当前日期小于或等于25,不可以发货
|
|
|
+ * 1.1.1.3.如果交货日期大于下月,不可以发货
|
|
|
+ * 1.1.2.物料备料提前期为具体天数
|
|
|
+ * 1.1.2.1.交货日期小于备料提前期 + 当前日期,可以发货
|
|
|
+ * 1.1.2.2.其他状况不可以发货
|
|
|
+ * 1.2.不属于同一年
|
|
|
+ * 1.2.1.如果备料提前期大于或等于0
|
|
|
+ * 1.2.1.1.当前日期+备料提前期+1大于收货日期,可以发货
|
|
|
+ * 1.2.1.2.其他条件不能发货
|
|
|
+ *
|
|
|
+ * </pre>
|
|
|
+ *
|
|
|
+ * @param delivery 发货日期
|
|
|
+ * @param stock 备料提前期
|
|
|
+ * @return 1: 等待发货 0: 可以发货
|
|
|
+ */
|
|
|
+ private static Short checkNoticeWaitStatus(Date delivery, Integer stock) {
|
|
|
Integer nowYear = DateUtils.getYear(new Date());
|
|
|
Integer delYear = DateUtils.getYear(delivery);
|
|
|
if (Objects.equals(nowYear, delYear)) {
|
|
|
@@ -152,8 +178,32 @@ public class SendNoticeTask {
|
|
|
} else {
|
|
|
return Constant.YES;
|
|
|
}
|
|
|
+ } else if (stock >= 0) {
|
|
|
+ Date resultDay = DateUtils.addDay(new Date(), stock);
|
|
|
+ if (DateUtils.compare(resultDay, delivery, DateUtils.COMPARE_DAY) == 1) {
|
|
|
+ return Constant.NO;
|
|
|
+ } else {
|
|
|
+ return Constant.YES;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (stock >= 0) {
|
|
|
+ Date resultDay = DateUtils.addDay(new Date(), stock + 1);
|
|
|
+ if (DateUtils.compare(resultDay, delivery, DateUtils.COMPARE_DAY) == 1) {
|
|
|
+ return Constant.NO;
|
|
|
+ } else {
|
|
|
+ return Constant.YES;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- return Constant.NO;
|
|
|
+ return Constant.YES;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) throws ParseException {
|
|
|
+ Long start = System.currentTimeMillis();
|
|
|
+ Date date = DateUtils.YMD.parse("2019-01-06");
|
|
|
+ System.out.println(checkNoticeWaitStatus(date, 60));
|
|
|
+ Long cost = System.currentTimeMillis() - start;
|
|
|
+ System.out.println("cost: " + cost);
|
|
|
}
|
|
|
}
|