|
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import com.mixsmart.utils.CustomFunction;
|
|
|
import com.mixsmart.utils.ListUtils;
|
|
|
+import com.mixsmart.utils.StringUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -16,8 +17,10 @@ import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.core.tool.utils.RegexUtil;
|
|
|
+import org.springblade.core.tool.utils.StringPool;
|
|
|
import org.springblade.manager.dto.*;
|
|
|
import org.springblade.manager.entity.Formula;
|
|
|
+import org.springblade.manager.service.IExcelTabService;
|
|
|
import org.springblade.manager.service.impl.FormulaServiceImpl;
|
|
|
import org.springblade.manager.wrapper.FormulaWrapper;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -25,6 +28,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
|
+import java.io.FileNotFoundException;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -39,6 +43,7 @@ import java.util.stream.Collectors;
|
|
|
@Api(value = "公式脚本", tags = "公式脚本")
|
|
|
public class FormulaController {
|
|
|
private final FormulaServiceImpl service;
|
|
|
+ private final IExcelTabService tabService;
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
/**
|
|
|
* 新增或修改
|
|
@@ -173,18 +178,33 @@ public class FormulaController {
|
|
|
@GetMapping("/range")
|
|
|
@ApiOperationSupport(order = 10)
|
|
|
@ApiOperation(value = "自动填充数据", notes = "根据设计值、偏差范围、频率自动填充数据")
|
|
|
- public R<Map<String,List<Object>>> rangeList(RangeInfo info) {
|
|
|
+ public R<Map<String,Object>> rangeList(RangeInfo info) throws FileNotFoundException {
|
|
|
if(info.verify()){
|
|
|
- Map<String,List<Object>> map = new HashMap<>();
|
|
|
if(Func.isNotEmpty(info.getPkId())){
|
|
|
Map<String,Object> data = this.jdbcTemplate.queryForMap("SELECT a.e_allow_deviation as dev from m_wbs_form_element a left join m_wbs_tree b on a.f_id=b.id left join m_wbs_tree_contract c on c.init_table_name=b.init_table_name where c.p_key_id="+info.getPkId()+" and a.e_key='"+info.getKey()+"'");
|
|
|
if(Func.isNotEmpty(data.get("dev"))){
|
|
|
info.setDev(Func.toStr(data.get("dev")));
|
|
|
}
|
|
|
}
|
|
|
- List<Object> data = CustomFunction.rangeList(info.getSize(),info.getDesign(),info.getDev(),1,0,1);
|
|
|
- map.put(info.getKey(),data);
|
|
|
- return R.data(map);
|
|
|
+ if(Func.isBlank(info.getDev())){
|
|
|
+ info.setDev("-3,3");
|
|
|
+ }
|
|
|
+ Map<String,String> keymap = this.tabService.getTablbCols(info.getPkId().toString(),null);
|
|
|
+ if(!keymap.containsKey(info.getKey())){
|
|
|
+ return R.fail("获取元素定位失败");
|
|
|
+ }
|
|
|
+ int scale=StringUtils.getScale(info.getDesign(),info.getDev());
|
|
|
+ List<Object> data = CustomFunction.rangeList(info.getSize(),info.getDesign(),info.getDev(),1,scale,1);
|
|
|
+ String[] dw = keymap.get(info.getKey()).split(StringPool.SEMICOLON);
|
|
|
+ Map<String,Object> result = new HashMap<>();
|
|
|
+ for(int i=0;i<dw.length;i++){
|
|
|
+ if(data.size()>i){
|
|
|
+ result.put(info.getKey()+"__"+dw[i],data.get(i));
|
|
|
+ }else{
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(result);
|
|
|
}
|
|
|
return R.fail("无数据");
|
|
|
}
|