Selaa lähdekoodia

1.机理模型预测配置接口 2.预测对比返回处理百分百

王苗苗 1 kuukausi sitten
vanhempi
commit
52c67a84af

+ 106 - 0
slibra-admin/src/main/java/com/slibra/web/controller/business/TPredictConfController.java

@@ -0,0 +1,106 @@
+package com.slibra.web.controller.business;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.slibra.common.annotation.Log;
+import com.slibra.common.core.controller.BaseController;
+import com.slibra.common.core.domain.AjaxResult;
+import com.slibra.common.enums.BusinessType;
+import com.slibra.business.domain.TPredictConf;
+import com.slibra.business.service.ITPredictConfService;
+import com.slibra.common.utils.poi.ExcelUtil;
+import com.slibra.common.core.page.TableDataInfo;
+
+/**
+ * 机理模型预测配置Controller
+ * 
+ * @author slibra
+ * @date 2025-02-11
+ */
+@RestController
+@RequestMapping("/business/predictConf")
+public class TPredictConfController extends BaseController
+{
+    @Autowired
+    private ITPredictConfService tPredictConfService;
+
+    /**
+     * 查询机理模型预测配置列表
+     */
+    @PreAuthorize("@ss.hasPermi('business:conf:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(TPredictConf tPredictConf)
+    {
+        startPage();
+        List<TPredictConf> list = tPredictConfService.selectTPredictConfList(tPredictConf);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出机理模型预测配置列表
+     */
+    @PreAuthorize("@ss.hasPermi('business:conf:export')")
+    @Log(title = "机理模型预测配置", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, TPredictConf tPredictConf)
+    {
+        List<TPredictConf> list = tPredictConfService.selectTPredictConfList(tPredictConf);
+        ExcelUtil<TPredictConf> util = new ExcelUtil<TPredictConf>(TPredictConf.class);
+        util.exportExcel(response, list, "机理模型预测配置数据");
+    }
+
+    /**
+     * 获取机理模型预测配置详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('business:conf:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return success(tPredictConfService.selectTPredictConfById(id));
+    }
+
+    /**
+     * 新增机理模型预测配置
+     */
+    @PreAuthorize("@ss.hasPermi('business:conf:add')")
+    @Log(title = "机理模型预测配置", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TPredictConf tPredictConf)
+    {
+        tPredictConf.setCreateBy(getUsername());
+        return toAjax(tPredictConfService.insertTPredictConf(tPredictConf));
+    }
+
+    /**
+     * 修改机理模型预测配置
+     */
+    @PreAuthorize("@ss.hasPermi('business:conf:edit')")
+    @Log(title = "机理模型预测配置", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TPredictConf tPredictConf)
+    {
+        tPredictConf.setUpdateBy(getUsername());
+        return toAjax(tPredictConfService.updateTPredictConf(tPredictConf));
+    }
+
+    /**
+     * 删除机理模型预测配置
+     */
+    @PreAuthorize("@ss.hasPermi('business:conf:remove')")
+    @Log(title = "机理模型预测配置", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(tPredictConfService.deleteTPredictConfByIds(ids));
+    }
+}

+ 10 - 0
slibra-admin/src/main/java/com/slibra/web/controller/business/TXinyiForecastComparisonController.java

@@ -122,6 +122,16 @@ public class TXinyiForecastComparisonController extends BaseController
                 BigDecimal yyErrorRateThree = tXinyiForecastComparison.getYyErrorRateThree();
                 if(!Objects.isNull(yyErrorRateThree))
                     tXinyiForecastComparison.setYyErrorRateThreeStr(DecimalUtils.getAbsAndScale(BigDecimal_100.multiply(yyErrorRateThree), 2) + PERCENT_SYMBOL);
+                //2025年02月12日17:03:02 下面处理机理模型的百分百的
+                BigDecimal jlErrorRateOne = tXinyiForecastComparison.getJlErrorRateOne();
+                if(!Objects.isNull(jlErrorRateOne))
+                    tXinyiForecastComparison.setJlErrorRateOneStr(DecimalUtils.getAbsAndScale(BigDecimal_100.multiply(jlErrorRateOne), 2) + PERCENT_SYMBOL);
+                BigDecimal jlErrorRateTwo = tXinyiForecastComparison.getJlErrorRateTwo();
+                if(!Objects.isNull(jlErrorRateTwo))
+                    tXinyiForecastComparison.setJlErrorRateTwoStr(DecimalUtils.getAbsAndScale(BigDecimal_100.multiply(jlErrorRateTwo), 2) + PERCENT_SYMBOL);
+                BigDecimal jlErrorRateThree = tXinyiForecastComparison.getJlErrorRateThree();
+                if(!Objects.isNull(jlErrorRateThree))
+                    tXinyiForecastComparison.setJlErrorRateThreeStr(DecimalUtils.getAbsAndScale(BigDecimal_100.multiply(jlErrorRateThree), 2) + PERCENT_SYMBOL);
             }
         }
     }

+ 9 - 0
slibra-system/src/main/java/com/slibra/business/domain/TXinyiForecastComparison.java

@@ -90,6 +90,9 @@ public class TXinyiForecastComparison extends BaseEntity
     @Excel(name = "机理模型预测值1差值")
     private BigDecimal jlOneSubtract;
 
+    @Excel(name = "机理模型预测值1百分比误差")
+    private String jlErrorRateOneStr;
+
     /** 预测时间2 */
     @Excel(name = "预测2时间")
     private String forecastTimeTwo;
@@ -138,6 +141,9 @@ public class TXinyiForecastComparison extends BaseEntity
     @Excel(name = "机理模型预测值2差值")
     private BigDecimal jlTwoSubtract;
 
+    @Excel(name = "机理模型预测值2百分比误差")
+    private String jlErrorRateTwoStr;
+
     /** 预测时间3 */
     @Excel(name = "预测3时间")
     private String forecastTimeThree;
@@ -186,6 +192,9 @@ public class TXinyiForecastComparison extends BaseEntity
     @Excel(name = "机理模型预测值3差值")
     private BigDecimal jlThreeSubtract;
 
+    @Excel(name = "机理模型预测值3百分比误差")
+    private String jlErrorRateThreeStr;
+
     /** 删除标志(0代表存在 2代表删除) */
     private Long delFlag;
 

+ 30 - 0
slibra-system/src/main/java/com/slibra/business/service/impl/TPredictConfServiceImpl.java

@@ -1,12 +1,16 @@
 package com.slibra.business.service.impl;
 
 import java.util.List;
+import java.util.Objects;
+
+import com.slibra.common.exception.ServiceException;
 import com.slibra.common.utils.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.slibra.business.mapper.TPredictConfMapper;
 import com.slibra.business.domain.TPredictConf;
 import com.slibra.business.service.ITPredictConfService;
+import org.springframework.util.CollectionUtils;
 
 /**
  * 机理模型预测配置Service业务层处理
@@ -54,6 +58,16 @@ public class TPredictConfServiceImpl implements ITPredictConfService
     public int insertTPredictConf(TPredictConf tPredictConf)
     {
         tPredictConf.setCreateTime(DateUtils.getNowDate());
+        //校验类型
+        Integer type = tPredictConf.getType();
+        if(Objects.isNull(type))
+            throw new ServiceException("必须选择对应的类型");
+        //查询同类型的是否已经添加过了
+        TPredictConf tPredictConfReq = new TPredictConf();
+        tPredictConfReq.setType(type);
+        List<TPredictConf> tPredictConfList = this.tPredictConfMapper.selectTPredictConfList(tPredictConfReq);
+        if(!CollectionUtils.isEmpty(tPredictConfList))
+            throw new ServiceException("对应的预测类型已经有了,不可以重复添加");
         return tPredictConfMapper.insertTPredictConf(tPredictConf);
     }
 
@@ -66,6 +80,22 @@ public class TPredictConfServiceImpl implements ITPredictConfService
     @Override
     public int updateTPredictConf(TPredictConf tPredictConf)
     {
+        Integer type = tPredictConf.getType();
+        if(Objects.isNull(type))
+            throw new ServiceException("必须选择对应的类型");
+        //查询同类型的是否已经添加过了
+        TPredictConf tPredictConfReq = new TPredictConf();
+        tPredictConfReq.setType(type);
+        List<TPredictConf> tPredictConfList = this.tPredictConfMapper.selectTPredictConfList(tPredictConfReq);
+        if(!CollectionUtils.isEmpty(tPredictConfList)){
+            int size = tPredictConfList.size();
+            if(size > 1)
+                throw new ServiceException("存在重复的预测类型数据,请检查!");
+            //只有一条 判断是不是当前的,如果不是,提示重复
+            TPredictConf tPredictConfExists = tPredictConfList.get(0);
+            if(!Objects.equals(tPredictConfExists.getId(), tPredictConf.getId()))
+                throw new ServiceException("当前要修改的预测类型已经存在了,请检查!");
+        }
         tPredictConf.setUpdateTime(DateUtils.getNowDate());
         return tPredictConfMapper.updateTPredictConf(tPredictConf);
     }