|
@@ -9,10 +9,13 @@ import es.template.pipenet.Component;
|
|
|
import es.template.pipenet.ComponetData;
|
|
|
import es.template.pipenet.Node;
|
|
|
import es.template.pipenet.Simulations;
|
|
|
+import tk.mybatis.mapper.entity.Example;
|
|
|
|
|
|
import javax.rmi.CORBA.Util;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
public class TemplateServer {
|
|
|
|
|
@@ -55,7 +58,7 @@ public class TemplateServer {
|
|
|
com.setPcom(c);
|
|
|
//获取非下拉值数据
|
|
|
List<ProComAttDto> atts =esdao.selectPrComAttListNoData(c.getPcId());
|
|
|
- com.setAtts(atts);
|
|
|
+ com.setAtts((atts));
|
|
|
|
|
|
//获取下拉值数据
|
|
|
List<ComponetData> datas = new ArrayList<>();
|
|
@@ -66,7 +69,7 @@ public class TemplateServer {
|
|
|
List<ProComAttDto> datts =esdao.selectPrComAttDataList(c.getPcId(),cdId);
|
|
|
ComponetData data = new ComponetData();
|
|
|
data.setCode(d.getCode());
|
|
|
- data.setAtts(datts);
|
|
|
+ data.setAtts((datts));
|
|
|
datas.add(data);
|
|
|
}
|
|
|
com.setDatas(datas);
|
|
@@ -91,8 +94,63 @@ public class TemplateServer {
|
|
|
List<ProComAttDto> comatt = esdao.selectSimulationsPrComAttDataList(pid);
|
|
|
sim.setType( comatt.get(0).getValue());//仿真类型
|
|
|
comatt.remove(0);
|
|
|
- sim.setAtts(comatt);
|
|
|
+ sim.setAtts((comatt));
|
|
|
return sim;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 转换单位
|
|
|
+ * @param proComAttDtoList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static List<ProComAttDto> conversionUnit(List<ProComAttDto> proComAttDtoList){
|
|
|
+ for(ProComAttDto proComAttDto:proComAttDtoList){
|
|
|
+ if(proComAttDto.getUnitType() == null || proComAttDto.getUnitType().equals("无")|| proComAttDto.getUnitType().isEmpty()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String unit = proComAttDto.getUnit();
|
|
|
+ String str = "无";
|
|
|
+ if(unit == null) continue;
|
|
|
+ if((!unit.isEmpty())&&(!str.equals(unit))){
|
|
|
+ //查询目前单位在es_unit表的记录
|
|
|
+ EsUnitMapper esmapper = UtilTools.getBean(EsUnitMapper.class);
|
|
|
+ EsUnitSQLBuilder sqlbuilder = new EsUnitSQLBuilder();
|
|
|
+ EsUnitSQLBuilder.Criteria criteria = sqlbuilder.createCriteria();
|
|
|
+ criteria.andGutIdEqualTo(proComAttDto.getUnitType());//在es_unit表中查找gutid = unit_type
|
|
|
+ criteria.andValueEqualTo(proComAttDto.getUnit());
|
|
|
+ EsUnit esUnit = esmapper.selectOneByExample(sqlbuilder);
|
|
|
+
|
|
|
+
|
|
|
+ //查询factor为1的单位在es_unit表中的记录
|
|
|
+ Example example = new Example(EsUnit.class);
|
|
|
+ example.createCriteria()
|
|
|
+ .andEqualTo("gutId", proComAttDto.getUnitType())
|
|
|
+ .andEqualTo("factor", new BigDecimal(1));
|
|
|
+ List<EsUnit> esUnitList = esmapper.selectByExample(example);
|
|
|
+ /*EsUnitSQLBuilder sqlbuilder_standardUnit = new EsUnitSQLBuilder();
|
|
|
+ EsUnitSQLBuilder.Criteria criteria1 = sqlbuilder_standardUnit.createCriteria();
|
|
|
+ criteria1.andGutIdEqualTo(proComAttDto.getUnitType());
|
|
|
+ criteria1.andFactorEqualTo(new BigDecimal(1));
|
|
|
+ //EsUnit esUnit_standardUnit = esmapper.selectOneByExample(sqlbuilder_standardUnit);
|
|
|
+ List<EsUnit> esUnitList = esmapper.selectByExample(criteria1);*/
|
|
|
+ EsUnit esUnit_standardUnit = esUnitList.get(0);
|
|
|
+
|
|
|
+ if(Objects.equals(esUnit.getFactor(), new BigDecimal(1))){//factor为1时不变
|
|
|
+ continue;
|
|
|
+ }else if(proComAttDto.getValue().isEmpty()) {
|
|
|
+ continue;
|
|
|
+ } else if (proComAttDto.getValue()==null) {
|
|
|
+ continue;
|
|
|
+ } else{//计算value值
|
|
|
+ double value = Double.parseDouble(proComAttDto.getValue());
|
|
|
+ double factor = esUnit.getFactor().doubleValue();
|
|
|
+ double offset = esUnit.getUtOffset().doubleValue();
|
|
|
+ double conversionValue = value / factor + offset;
|
|
|
+ proComAttDto.setValue(String.valueOf(conversionValue));
|
|
|
+ proComAttDto.setUnit(esUnit_standardUnit.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return proComAttDtoList;
|
|
|
+ }
|
|
|
|
|
|
}
|