Selaa lähdekoodia

年度计划信息中的枚举类信息(下拉框数据)
年度计划创建和修改时判断是否超额计划

buzhanyi 2 vuotta sitten
vanhempi
commit
1de31ad97d

+ 71 - 0
purchase-admin/src/main/java/com/ozs/web/controller/plan/EnumsOfPlanController.java

@@ -0,0 +1,71 @@
+package com.ozs.web.controller.plan;
+
+import com.ozs.common.core.controller.BaseController;
+import com.ozs.common.core.domain.AjaxResult;
+import com.ozs.common.core.domain.entity.SysDictData;
+import com.ozs.common.enums.PlanPurchaseMode;
+import com.ozs.common.enums.ProjectAttribute;
+import com.ozs.common.enums.ProjectStatus;
+import com.ozs.common.enums.ProjectTypes;
+import com.ozs.system.service.ISysDictTypeService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+/**
+ * 年度计划信息中的枚举类信息
+ *
+ * @author buzhanyi
+ */
+@RestController
+@RequestMapping("/plan/about")
+public class EnumsOfPlanController extends BaseController {
+
+    @Autowired
+    private ISysDictTypeService dictTypeService;
+
+    @ApiOperation(value = "年度计划信息中的枚举类信息(下拉框)")
+    @PostMapping("/getAboutEnums")
+    public AjaxResult getAboutEnums() {
+        HashMap<String, HashMap<String, String>> hashMap = new HashMap<>();
+        HashMap<String, String> projectTypesMap = new LinkedHashMap<>();
+        HashMap<String, String> projectStatusMap = new LinkedHashMap<>();
+        HashMap<String, String> planPurchaseModesMap = new LinkedHashMap<>();
+        HashMap<String, String> projectAttributes = new LinkedHashMap<>();
+        HashMap<String, String> purchaseServices = new LinkedHashMap<>();
+        //项目类型
+        for (ProjectTypes value : ProjectTypes.values()) {
+            projectTypesMap.put(value.getInfo(), value.getCode());
+        }
+        //项目审核状态
+        for (ProjectStatus value : ProjectStatus.values()) {
+            projectStatusMap.put(value.getInfo(), value.getCode());
+        }
+        //采购方式
+        for (PlanPurchaseMode value : PlanPurchaseMode.values()) {
+            planPurchaseModesMap.put(value.getInfo(), value.getCode());
+        }
+        //项目属性
+        for (ProjectAttribute value : ProjectAttribute.values()) {
+            projectAttributes.put(value.getInfo(), value.getCode());
+        }
+        List<SysDictData> data = dictTypeService.selectDictDataByType("purchase_services");
+        //采购服务站
+        for (SysDictData dictData : data) {
+            purchaseServices.put(dictData.getDictLabel(), dictData.getDictValue());
+        }
+        hashMap.put("ProjectTypes", projectTypesMap);
+        hashMap.put("ProjectStatus", projectStatusMap);
+        hashMap.put("PlanPurchaseModes", planPurchaseModesMap);
+        hashMap.put("ProjectAttributes", projectAttributes);
+        hashMap.put("purchaseServices", purchaseServices);
+        return AjaxResult.success(hashMap);
+    }
+
+}

+ 1 - 1
purchase-common/src/main/java/com/ozs/common/enums/ProjectAttribute.java

@@ -1,7 +1,7 @@
 package com.ozs.common.enums;
 
 /**
- * 项目类型
+ * 项目属性
  *
  * @author buzhanyi
  */

+ 79 - 2
purchase-system/src/main/java/com/ozs/plan/service/impl/PlanOfYearsServiceImpl.java

@@ -1,7 +1,9 @@
 package com.ozs.plan.service.impl;
 
 import com.ozs.common.core.domain.AjaxResult;
+import com.ozs.common.core.domain.entity.SysDictData;
 import com.ozs.common.enums.ProjectStatus;
+import com.ozs.common.enums.ProjectTypes;
 import com.ozs.common.exception.ServiceException;
 import com.ozs.common.utils.StringUtils;
 import com.ozs.common.utils.bean.BeanUtils;
@@ -11,6 +13,7 @@ import com.ozs.plan.doman.vo.requestVo.PlanOfYearsStandardVo;
 import com.ozs.plan.doman.vo.responseVo.PlanOfYearsResponseVo;
 import com.ozs.plan.mapper.PlanOfYearsMapper;
 import com.ozs.plan.service.PlanOfYearsService;
+import com.ozs.system.service.ISysDictTypeService;
 import com.ozs.system.service.impl.SysUserServiceImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -18,8 +21,11 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.validation.Validator;
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 
 /**
@@ -33,6 +39,8 @@ public class PlanOfYearsServiceImpl implements PlanOfYearsService {
     PlanOfYearsMapper planOfYearsMapper;
     @Autowired
     protected Validator validator;
+    @Autowired
+    private ISysDictTypeService dictTypeService;
 
     @Override
     public List<PlanOfYears> selectPlanOfYearsList(PlanOfYearsStandardVo vo) {
@@ -58,8 +66,30 @@ public class PlanOfYearsServiceImpl implements PlanOfYearsService {
         } catch (Exception e) {
             e.printStackTrace();
         }
-        //判断是否为超额计划---
-
+        //判断是否为超额计划
+        BigDecimal evaluation = yearsStandardVo.getEvaluation();
+        BigDecimal threshold = new BigDecimal(0);
+        //获取各个项目类型设定的概算金额阈值
+        List<SysDictData> data = dictTypeService.selectDictDataByType("sys_over_limit_threshold");
+        HashMap<String, String> thresholdMap = new LinkedHashMap<>();
+        //各个类型的概算金额阈值
+        for (SysDictData dictData : data) {
+            //    类型----阈值
+            thresholdMap.put(dictData.getDictLabel(), dictData.getDictValue());
+        }
+        //项目类型
+        for (ProjectTypes value : ProjectTypes.values()) {
+            if (yearsStandardVo.getProjectType().equals(value.getCode())) {
+                threshold = BigDecimal.valueOf(Long.parseLong(thresholdMap.get(value.getInfo())));
+            }
+            break;
+        }
+        if (evaluation.compareTo(threshold) == 1) {
+            //是超额项目
+            ofYears.setIsExcess("1");
+        } else {
+            ofYears.setIsExcess("0");
+        }
         ofYears.setProjectStatus(ProjectStatus.PLANWAITCOMMIT.getCode());
         ofYears.setCreateTime(new Date());
         planOfYearsMapper.insertPlanOfYears(ofYears);
@@ -100,6 +130,31 @@ public class PlanOfYearsServiceImpl implements PlanOfYearsService {
         } catch (Exception e) {
             e.printStackTrace();
         }
+        BigDecimal evaluation = ofYears.getEvaluation();
+        BigDecimal threshold = new BigDecimal(0);
+        //获取各个项目类型设定的概算金额阈值
+        List<SysDictData> data = dictTypeService.selectDictDataByType("sys_over_limit_threshold");
+        HashMap<String, String> thresholdMap = new LinkedHashMap<>();
+        //各个类型的概算金额阈值
+        for (SysDictData dictData : data) {
+            //    类型----阈值
+            thresholdMap.put(dictData.getDictLabel(), dictData.getDictValue());
+        }
+        //项目类型
+        for (ProjectTypes value : ProjectTypes.values()) {
+            if (ofYears.getProjectType().equals(value.getCode())) {
+                threshold = BigDecimal.valueOf(Long.parseLong(thresholdMap.get(value.getInfo())));
+            }
+            break;
+        }
+
+        if (evaluation.compareTo(threshold) == 1) {
+            //是超额项目
+            ofYears.setIsExcess("1");
+        } else {
+            ofYears.setIsExcess("0");
+        }
+
         planOfYearsMapper.updateById(ofYears);
         return AjaxResult.success();
     }
@@ -152,6 +207,28 @@ public class PlanOfYearsServiceImpl implements PlanOfYearsService {
 
     @Override
     public AjaxResult commit(PlanOfYearsStandardVo yearsStandardVo) {
+        //PlanOfYears byId = planOfYearsMapper.getById(yearsStandardVo.getPlanYearId());
+        //BigDecimal evaluation = byId.getEvaluation();
+        //BigDecimal threshold = new BigDecimal(0);
+        ////获取各个项目类型设定的概算金额阈值
+        //List<SysDictData> data = dictTypeService.selectDictDataByType("sys_over_limit_threshold");
+        //HashMap<String, String> thresholdMap = new LinkedHashMap<>();
+        ////各个类型的概算金额阈值
+        //for (SysDictData dictData : data) {
+        //    //    类型----阈值
+        //    thresholdMap.put(dictData.getDictLabel(), dictData.getDictValue());
+        //}
+        ////项目类型
+        //for (ProjectTypes value : ProjectTypes.values()) {
+        //    if (byId.getProjectType().equals(value.getCode())) {
+        //        threshold = BigDecimal.valueOf(Long.parseLong(thresholdMap.get(value.getInfo())));
+        //    }
+        //    break;
+        //}
+        //
+        //if (evaluation.compareTo(threshold) == 1) {
+        //    //是超额项目
+        //}
 
         int commit = planOfYearsMapper.commit(yearsStandardVo.getPlanYearId());
         if (commit != 1) {