|
@@ -1,6 +1,8 @@
|
|
|
package com.jjt.check.controller;
|
|
|
|
|
|
import com.deepoove.poi.XWPFTemplate;
|
|
|
+import com.jjt.biz.domain.BizObjMetrics;
|
|
|
+import com.jjt.biz.service.IBizObjMetricsService;
|
|
|
import com.jjt.check.domain.CheckConfig;
|
|
|
import com.jjt.check.domain.CheckRecord;
|
|
|
import com.jjt.check.domain.CheckRecordDetail;
|
|
@@ -14,14 +16,18 @@ import com.jjt.common.core.domain.AjaxResult;
|
|
|
import com.jjt.common.core.page.TableDataInfo;
|
|
|
import com.jjt.common.enums.BusinessType;
|
|
|
import com.jjt.common.utils.DateUtils;
|
|
|
+import com.jjt.common.utils.IntervalUtil;
|
|
|
import com.jjt.common.utils.bean.BeanUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import javafx.util.Pair;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
@@ -134,6 +140,9 @@ public class CheckConfigController extends BaseController {
|
|
|
return success(crService.selectCheckRecordByCrId(crId));
|
|
|
}
|
|
|
|
|
|
+ @Resource
|
|
|
+ private IBizObjMetricsService omService;
|
|
|
+
|
|
|
/**
|
|
|
* 修改自动巡检记录明细
|
|
|
*/
|
|
@@ -149,15 +158,59 @@ public class CheckConfigController extends BaseController {
|
|
|
crService.insertCheckRecord(cr);
|
|
|
int errors = 0;
|
|
|
for (CheckConfig checkConfig : list) {
|
|
|
+ String e = checkConfig.getCheckCode().split("_")[1];
|
|
|
+ int pos = Integer.parseInt(e) - 1;
|
|
|
+
|
|
|
CheckRecordDetail crd = new CheckRecordDetail();
|
|
|
BeanUtils.copyProperties(checkConfig, crd);
|
|
|
crd.setCrId(cr.getCrId());
|
|
|
- String e = checkConfig.getCheckCode().split("_")[1];
|
|
|
- int pos = Integer.parseInt(e) - 1;
|
|
|
- crd.setResultL(vo.getLeft()[pos]);
|
|
|
- crd.setResultR(vo.getRight()[pos]);
|
|
|
- if ("异常".equals(crd.getResultR())) {
|
|
|
- errors++;
|
|
|
+ BizObjMetrics bom = new BizObjMetrics();
|
|
|
+ Long metricsId = checkConfig.getMetricsId();
|
|
|
+ if (metricsId != null) {
|
|
|
+ bom.setMetricsId(checkConfig.getMetricsId());
|
|
|
+ List<BizObjMetrics> oms = omService.selectBizObjMetricsList(bom);
|
|
|
+ if (oms.size() > 0) {
|
|
|
+ if ("1".equals(checkConfig.getCheckMethod())) {
|
|
|
+ //平均值
|
|
|
+ BigDecimal total = BigDecimal.ZERO;
|
|
|
+ for (BizObjMetrics om : oms) {
|
|
|
+ total = total.add(om.getDValue());
|
|
|
+ }
|
|
|
+ BigDecimal avg = total.divide(BigDecimal.valueOf(oms.size()), 2, RoundingMode.HALF_UP);
|
|
|
+ boolean flag = IntervalUtil.inNumRange(avg.floatValue(), checkConfig.getCheckRule());
|
|
|
+ Pair<String, String> pair = CheckExportVO.checkV(flag, avg.floatValue(), pos);
|
|
|
+ crd.setResultL(pair.getKey());
|
|
|
+ crd.setResultR(pair.getValue());
|
|
|
+ if (flag) {
|
|
|
+ errors++;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //发现一个就算异常
|
|
|
+ for (BizObjMetrics om : oms) {
|
|
|
+ boolean flag = IntervalUtil.inNumRange(om.getDValue().floatValue(), checkConfig.getCheckRule());
|
|
|
+ Pair<String, String> pair = CheckExportVO.checkV(true, 0f, pos);
|
|
|
+ crd.setResultL(pair.getKey());
|
|
|
+ crd.setResultR(pair.getValue());
|
|
|
+ if (flag) {
|
|
|
+ errors++;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ BigDecimal v = BigDecimal.valueOf(Math.random() * 100).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ boolean flag = false;
|
|
|
+ if (v.intValue() % 2 == 0) {
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ Pair<String, String> pair = CheckExportVO.checkV(flag, v.floatValue(), pos);
|
|
|
+ crd.setResultL(pair.getKey());
|
|
|
+ crd.setResultR(pair.getValue());
|
|
|
+ if (flag) {
|
|
|
+ errors++;
|
|
|
+ }
|
|
|
}
|
|
|
crdService.insertCheckRecordDetail(crd);
|
|
|
details.add(crd);
|
|
@@ -167,7 +220,6 @@ public class CheckConfigController extends BaseController {
|
|
|
cr.setDetailList(details);
|
|
|
crService.updateCheckRecord(cr);
|
|
|
return success(cr);
|
|
|
-// return toAjax(checkConfigService.updateCheckRecordDetail(checkRecordDetail));
|
|
|
}
|
|
|
|
|
|
/**
|