Преглед на файлове

创建计划是否在提报范围内

buzhanyi преди 2 години
родител
ревизия
c1497304a1

+ 54 - 0
purchase-system/src/main/java/com/ozs/plan/service/impl/PlanQuarterServiceImpl.java

@@ -190,6 +190,9 @@ public class PlanQuarterServiceImpl extends ServiceImpl<PlanQuarterMapper, PlanQ
         if (planQuarterMapper.countProjectName(quarterStandardVo.getProjectName()) > 0) {
             return AjaxResult.error("该项目名称已经存在");
         }
+        if (!isBetweenValue(quarterStandardVo)) {
+            return AjaxResult.error("所创计划不在提报日期内!");
+        }
         //默认未超额
         if (ObjectUtils.isEmpty(quarterStandardVo.getIsExcess())) {
             quarterStandardVo.setIsExcess("0");
@@ -265,6 +268,9 @@ public class PlanQuarterServiceImpl extends ServiceImpl<PlanQuarterMapper, PlanQ
         if (planQuarterMapper.countProjectNameOther(quarterStandardVo.getProjectName(), String.valueOf(quarterStandardVo.getPlanPracticalId())) > 0) {
             return AjaxResult.error("该项目名称已经存在");
         }
+        if (!isBetweenValue(quarterStandardVo)) {
+            return AjaxResult.error("所创计划不在提报日期内!");
+        }
         //默认未超额
         if (ObjectUtils.isEmpty(quarterStandardVo.getIsExcess())) {
             quarterStandardVo.setIsExcess("0");
@@ -733,5 +739,53 @@ public class PlanQuarterServiceImpl extends ServiceImpl<PlanQuarterMapper, PlanQ
         return subTips;
     }
 
+    //是否在提报时间内
+    public Boolean isBetweenValue(PlanQuarterStandardVo quarterStandardVo) {
+        //获取年度计划提报时间的阈值
+        //获取季度计划各个季度提报时间的阈值
+        List<SysDictData> supTime = dictTypeService.selectDictDataByType("sys_quarterly_plan");
+        HashMap<String, String> thresholdMap = new LinkedHashMap<>();
+        //各个季度提报时间的阈值
+        for (SysDictData dictData : supTime) {
+            //    季度----阈值
+            thresholdMap.put(dictData.getDictLabel(), dictData.getDictValue());
+        }
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date thresholdTimeStart = null;
+        Date thresholdTimeEnd = null;
+        Date subTime = quarterStandardVo.getPlanDemandSubTime();
+        try {
+            for (QuarterEnum val : QuarterEnum.values()) {
+                if (val.getInfo().contains(subTime.getMonth() + "")) {
+                    switch (val.getCode()) {
+                        case "1":
+                            thresholdTimeStart = dateFormat.parse(thresholdMap.get("第一季度开始时间"));
+                            thresholdTimeEnd = dateFormat.parse(thresholdMap.get("第一季度结束时间"));
+                            break;
+                        case "2":
+                            thresholdTimeStart = dateFormat.parse(thresholdMap.get("第二季度开始时间"));
+                            thresholdTimeEnd = dateFormat.parse(thresholdMap.get("第二季度结束时间"));
+                            break;
+                        case "3":
+                            thresholdTimeStart = dateFormat.parse(thresholdMap.get("第三季度开始时间"));
+                            thresholdTimeEnd = dateFormat.parse(thresholdMap.get("第三季度结束时间"));
+                            break;
+                        default:
+                            thresholdTimeStart = dateFormat.parse(thresholdMap.get("第四季度开始时间"));
+                            thresholdTimeEnd = dateFormat.parse(thresholdMap.get("第四季度结束时间"));
+                    }
+                    break;
+                }
+            }
+            if (!ObjectUtils.isEmpty(thresholdTimeStart) && !ObjectUtils.isEmpty(thresholdTimeEnd)) {
+                if (!subTime.after(thresholdTimeStart) && !subTime.before(thresholdTimeEnd)) {
+                    return false;
+                }
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return true;
+    }
 
 }

+ 34 - 0
purchase-system/src/main/java/com/ozs/plan/service/impl/PlanYearsServiceImpl.java

@@ -219,6 +219,9 @@ public class PlanYearsServiceImpl extends ServiceImpl<PlanYearsMapper, PlanYears
         if (planYearsMapper.countProjectName(yearsStandardVo.getProjectName()) > 0) {
             return AjaxResult.error("该项目名称已经存在");
         }
+        if (!isBetweenValue(yearsStandardVo)) {
+            return AjaxResult.error("所创计划不在提报日期内!");
+        }
         //默认未超额
         if (ObjectUtils.isEmpty(yearsStandardVo.getIsExcess())) {
             yearsStandardVo.setIsExcess("0");
@@ -295,6 +298,9 @@ public class PlanYearsServiceImpl extends ServiceImpl<PlanYearsMapper, PlanYears
         if (planYearsMapper.countProjectNameOther(yearsStandardVo.getProjectName(), String.valueOf(yearsStandardVo.getPlanYearId())) > 0) {
             return AjaxResult.error("该项目名称已经存在");
         }
+        if (!isBetweenValue(yearsStandardVo)) {
+            return AjaxResult.error("所创计划不在提报日期内!");
+        }
         //默认未超额
         if (ObjectUtils.isEmpty(yearsStandardVo.getIsExcess())) {
             yearsStandardVo.setIsExcess("0");
@@ -327,6 +333,34 @@ public class PlanYearsServiceImpl extends ServiceImpl<PlanYearsMapper, PlanYears
         return AjaxResult.success();
     }
 
+    //是否在提报时间内
+    public Boolean isBetweenValue(PlanYearsStandardVo yearsStandardVo) {
+        //获取年度计划提报时间的阈值
+        List<SysDictData> supTime = dictTypeService.selectDictDataByType("sys_annual_plan");
+        HashMap<String, String> thresholdMap = new LinkedHashMap<>();
+        //年度提报时间的阈值
+        for (SysDictData dictData : supTime) {
+            //    字段名称----阈值
+            thresholdMap.put(dictData.getDictLabel(), dictData.getDictValue());
+        }
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date thresholdTimeStart = null;
+        Date thresholdTimeEnd = null;
+        Date subTime = yearsStandardVo.getPlanDemandSubTime();
+        try {
+            if (!ObjectUtils.isEmpty(thresholdTimeStart) && !ObjectUtils.isEmpty(thresholdTimeEnd)) {
+                thresholdTimeStart = dateFormat.parse(thresholdMap.get("起止时间开始"));
+                thresholdTimeEnd = dateFormat.parse(thresholdMap.get("起止时间结束"));
+                if (!subTime.after(thresholdTimeStart) && !subTime.before(thresholdTimeEnd)) {
+                    return false;
+                }
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return true;
+    }
+
     @Transactional
     @Override
     public String importPlanYears(List<PlanYearsStandardVo> planYears, boolean isUpdateSupport, LoginUser loginUser) {