package com.iailab.module.pms.coalquality.modules.analysis.service.impl;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.iailab.framework.common.service.impl.BaseServiceImpl;
|
import com.iailab.framework.common.util.object.ConvertUtils;
|
import com.iailab.framework.tenant.core.aop.TenantIgnore;
|
import com.iailab.module.pms.coalquality.common.enums.FcfaType;
|
import com.iailab.module.pms.coalquality.modules.analysis.dao.CoalWashCurvesChartDao;
|
import com.iailab.module.pms.coalquality.modules.analysis.dto.CoalWashCurvesChartDTO;
|
import com.iailab.module.pms.coalquality.modules.analysis.entity.CoalWashCurvesChartEntity;
|
import com.iailab.module.pms.coalquality.modules.analysis.service.CoalWashCurvesChartService;
|
import com.iailab.module.pms.coalquality.modules.analysis.service.CoalWashCurvesDetService;
|
import com.mathworks.toolbox.javabuilder.MWCellArray;
|
import com.mathworks.toolbox.javabuilder.MWNumericArray;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import washabilityCurve20230915.WashCurve;
|
|
import java.math.BigDecimal;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 可选性曲线图
|
*
|
* @author PanZhibao
|
* @Description
|
* @createTime 2023年01月19日 23:25:00
|
*/
|
@Service
|
public class CoalWashCurvesChartServiceImpl extends BaseServiceImpl<CoalWashCurvesChartDao, CoalWashCurvesChartEntity>
|
implements CoalWashCurvesChartService {
|
|
@Autowired
|
private CoalWashCurvesDetService coalWashCurvesDetService;
|
|
private final String CURVES_TYPE_FITTING = "1";
|
|
@Override
|
@TenantIgnore
|
public CoalWashCurvesChartDTO getByCurvesId(String curvesId) {
|
CoalWashCurvesChartEntity entity = baseDao.selectOne(new QueryWrapper<CoalWashCurvesChartEntity>().eq("curves_id", curvesId));
|
return ConvertUtils.sourceToTarget(entity, CoalWashCurvesChartDTO.class);
|
}
|
|
@Override
|
@TenantIgnore
|
public void update(CoalWashCurvesChartDTO dto) {
|
baseDao.delete(new QueryWrapper<CoalWashCurvesChartEntity>().eq("curves_id", dto.getCurvesId()));
|
CoalWashCurvesChartEntity entity = ConvertUtils.sourceToTarget(dto, CoalWashCurvesChartEntity.class);
|
insert(entity);
|
}
|
|
@Override
|
public CoalWashCurvesChartDTO draw(CoalWashCurvesChartDTO dto) {
|
|
String curvesType = dto.getCurvesType();
|
Map<String, Object> drawParams = coalWashCurvesDetService.getDrawParams(dto.getCurvesId());
|
|
try {
|
double[] densitySrcData = new double[]{1.3, 1.4, 1.5, 1.6, 1.8};
|
if(FcfaType.THREE.getCode().equals(dto.getFcfa())) {
|
densitySrcData = new double[]{1.4, 1.8};
|
}
|
|
double[][] floatSrcData = (double[][]) drawParams.get("floatSrcData");
|
double[][] densityScopeSrcData = (double[][]) drawParams.get("densityScopeSrcData");
|
double[] coeffSrcData = {};
|
|
WashCurve wc = new WashCurve();
|
Object[] allResult = wc.washabilityCurve(2, densitySrcData, floatSrcData, densityScopeSrcData, Integer.parseInt(curvesType), coeffSrcData);
|
MWNumericArray temp = (MWNumericArray) allResult[0];
|
double[][] coefficient = (double[][]) temp.toDoubleArray();
|
MWCellArray temp1 = (MWCellArray) allResult[1];
|
double[][] test1 = (double[][]) temp1.get(1);
|
double[] xAxis1 = test1[0];
|
double[][] test2 = (double[][]) temp1.get(2);
|
double[] xAxis2 = test2[0];
|
double[][] test3 = (double[][]) temp1.get(3);
|
//double[] floatVue = test3[0];
|
double[][] test4 = (double[][]) temp1.get(4);
|
double[] cellVue = test4[0];
|
double[][] test5 = (double[][]) temp1.get(5);
|
// double[] sinkVue = test5[0];
|
double[][] test6 = (double[][]) temp1.get(6);
|
double[] densityDataResult = test6[0];
|
double[][] test7 = (double[][]) temp1.get(7);
|
double[] densityScopeData = test7[0];
|
double[][] floatPoint = (double[][]) temp1.get(8);
|
double[][] densePoint = (double[][]) temp1.get(9);
|
double[][] denseScopePoint = (double[][]) temp1.get(10);
|
|
List<Double> xAxis1List = new ArrayList<>();
|
for(int i = 0; i < xAxis1.length; i ++) {
|
xAxis1List.add(new BigDecimal(xAxis1[i]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
}
|
List<Double> xAxis2List = new ArrayList<>();
|
for(int i = 0; i < xAxis2.length; i ++) {
|
xAxis2List.add(new BigDecimal(xAxis2[i]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
}
|
List<Double> floatVue = new ArrayList<>();
|
for(int i = 0; i < test3[0].length; i ++) {
|
floatVue.add(new BigDecimal(test3[0][i]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
}
|
List<Double> sinkVue = new ArrayList<>();
|
for(int i = 0; i < test5[0].length; i ++) {
|
sinkVue.add(new BigDecimal(test5[0][i]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
}
|
List<Double> cellVueList = new ArrayList<>();
|
for(int i = 0; i < cellVue.length; i ++) {
|
cellVueList.add(new BigDecimal(cellVue[i]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
}
|
List<Double> densityDataList = new ArrayList<>();
|
for(int i = 0; i < densityDataResult.length; i ++) {
|
densityDataList.add(new BigDecimal(densityDataResult[i]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
}
|
Map<Integer, Integer> emptyDs = new HashMap<>();
|
if (CURVES_TYPE_FITTING.equals(curvesType)) {
|
int k = 0;
|
for (int i = 0; i < (densityDataResult.length - 1); i++ ) {
|
if (densityDataResult[i] != 0) {
|
k = i - 1;
|
break;
|
}
|
}
|
if (k <= 0) {
|
k = 15;
|
}
|
|
for (int j = 0; j < k + 10; j++) {
|
emptyDs.put(j, j);
|
}
|
}
|
|
List<Double> densityScopeList = new ArrayList<>();
|
for(int i = 0; i < densityScopeData.length; i ++) {
|
if (emptyDs.containsKey(i)) {
|
densityScopeList.add(null);
|
continue;
|
}
|
densityScopeList.add(new BigDecimal(densityScopeData[i]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
}
|
dto.setDensitySrcData(JSONObject.toJSONString(densitySrcData));
|
dto.setFloatSrcData(JSONObject.toJSONString(floatSrcData));
|
dto.setDensityScopeSrcData(JSONObject.toJSONString(densityScopeSrcData));
|
dto.setCoeffSrcData(JSONObject.toJSONString(coeffSrcData));
|
|
dto.setXAxisData1(JSONObject.toJSONString(xAxis1List));
|
dto.setXAxisData2(JSONObject.toJSONString(xAxis2List));
|
dto.setFloatPointData(JSONObject.toJSONString(floatPoint));
|
dto.setDensityPointData(JSONObject.toJSONString(densePoint));
|
dto.setDensityScopePointData(JSONObject.toJSONString(denseScopePoint));
|
dto.setCellData(JSONObject.toJSONString(cellVueList));
|
dto.setDensityData(JSONObject.toJSONString(densityDataList));
|
dto.setDensityScopeData(JSONObject.toJSONString(densityScopeList));
|
dto.setFloatData(JSONObject.toJSONString(floatVue));
|
dto.setSinkData(JSONObject.toJSONString(sinkVue));
|
this.update(dto);
|
return dto;
|
} catch (Exception ex) {
|
ex.printStackTrace();
|
}
|
return null;
|
}
|
}
|