1. 指标子集映射

This commit is contained in:
李玉东 2025-09-26 14:12:09 +08:00
parent 516a03e46a
commit ff5126f80b
26 changed files with 320 additions and 310 deletions

View File

@ -8,6 +8,8 @@ import com.hshh.model.service.FormFieldConfigService;
import com.hshh.model.service.FormValueService; import com.hshh.model.service.FormValueService;
import com.hshh.model.service.ModelDefineService; import com.hshh.model.service.ModelDefineService;
import com.hshh.system.annotation.LogOperation; import com.hshh.system.annotation.LogOperation;
import com.hshh.system.base.entity.DictItem;
import com.hshh.system.base.service.DictItemService;
import com.hshh.system.common.bean.BaseController; import com.hshh.system.common.bean.BaseController;
import com.hshh.system.common.bean.ErrorField; import com.hshh.system.common.bean.ErrorField;
import com.hshh.system.common.bean.OperateResult; import com.hshh.system.common.bean.OperateResult;
@ -22,6 +24,7 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -61,6 +64,8 @@ public class DataController extends BaseController {
*/ */
@Resource @Resource
private DataRecordService dataRecordService; private DataRecordService dataRecordService;
@Resource
private DictItemService dictItemService;
/** /**
* 默认排序最大 999 * 默认排序最大 999
*/ */
@ -93,13 +98,17 @@ public class DataController extends BaseController {
formConfigList.forEach(formFieldConfig -> { formConfigList.forEach(formFieldConfig -> {
headerMap.put(formFieldConfig.getFieldName(), formFieldConfig.getFieldLabel()); headerMap.put(formFieldConfig.getFieldName(), formFieldConfig.getFieldLabel());
}); });
Map<String, FormFieldConfig> formFieldConfigMap = formConfigList.stream().collect(
Collectors.toMap(FormFieldConfig::getFieldName, formFieldConfig -> formFieldConfig));
Map<Integer, List<DictItem>> dictMap = dictItemService.dictItemMap();
model.addAttribute("headerMap", headerMap); model.addAttribute("headerMap", headerMap);
//查询模型数据 //查询模型数据
List<FormValue> formDataList = formValueService.list(request); List<FormValue> formDataList = formValueService.list(request);
List<Map<String, Object>> listMap = new ArrayList<>(); List<Map<String, Object>> listMap = new ArrayList<>();
formDataList.forEach(formData -> { formDataList.forEach(formData -> {
listMap.add(formData.toMap()); //转为map对象放入listMap中 listMap.add(formData.toMap(formFieldConfigMap, dictMap)); //转为map对象放入listMap中
}); });
Long total = formValueService.count(request); Long total = formValueService.count(request);
setPaginationInfo(request, listMap, total, model); setPaginationInfo(request, listMap, total, model);
@ -155,8 +164,8 @@ public class DataController extends BaseController {
@GetMapping("/getForm/{id}") @GetMapping("/getForm/{id}")
@Operation(summary = "获取form输入窗体", description = "根据模型ID获取form窗体") @Operation(summary = "获取form输入窗体", description = "根据模型ID获取form窗体")
@ResponseBody @ResponseBody
public OperateResult<String> getForm(@PathVariable("id") Integer id, public OperateResult<String> getForm(@PathVariable("id") Integer id
HttpServletRequest httpServletRequest) { ) {
return OperateResult.success(dataRecordService.html(id), ErrorMessage.SUCCESS.getMessage()); return OperateResult.success(dataRecordService.html(id), ErrorMessage.SUCCESS.getMessage());
} }
@ -171,8 +180,8 @@ public class DataController extends BaseController {
@PostMapping("/form/save") @PostMapping("/form/save")
@ResponseBody @ResponseBody
@Operation(summary = "保存记录", description = "保存对应模型ID对应的form表单记录") @Operation(summary = "保存记录", description = "保存对应模型ID对应的form表单记录")
public OperateResult<Void> saveRecord(@RequestBody FormValue formValue, public OperateResult<Void> saveRecord(@RequestBody FormValue formValue
HttpServletRequest httpServletRequest) { ) {
//验证字段合法性 //验证字段合法性
Integer modelId = formValue.getModelDefineId(); Integer modelId = formValue.getModelDefineId();
@ -197,7 +206,7 @@ public class DataController extends BaseController {
@GetMapping("/remove/{id}") @GetMapping("/remove/{id}")
@Operation(summary = "删除记录", description = "根据ID删除记录") @Operation(summary = "删除记录", description = "根据ID删除记录")
public OperateResult<Void> remove(@PathVariable("id") Integer id public OperateResult<Void> remove(@PathVariable("id") Integer id
) { ) {
formValueService.removeById(id); formValueService.removeById(id);
return OperateResult.success(); return OperateResult.success();
} }
@ -212,7 +221,7 @@ public class DataController extends BaseController {
@GetMapping("/{id}") @GetMapping("/{id}")
@Operation(summary = "删除记录", description = "根据ID删除记录") @Operation(summary = "删除记录", description = "根据ID删除记录")
public OperateResult<FormValue> view(@PathVariable("id") Integer id public OperateResult<FormValue> view(@PathVariable("id") Integer id
) { ) {
FormValue formValue = formValueService.getById(id); FormValue formValue = formValueService.getById(id);
if (formValue == null) { if (formValue == null) {
return OperateResult.error(null, ErrorMessage.ID_NOT_EXIT.getMessage(), return OperateResult.error(null, ErrorMessage.ID_NOT_EXIT.getMessage(),

View File

@ -28,5 +28,5 @@ public interface DataRecordService {
* @return 错误信息 * @return 错误信息
*/ */
List<ErrorField> getErrorField(List<FormFieldConfig> formConfigList, FormValue formValue); List<ErrorField> getErrorField(List<FormFieldConfig> formConfigList, FormValue formValue);
void deleteFromByModelId(Integer id);
} }

View File

@ -8,10 +8,13 @@ import com.hshh.model.entity.FormValue;
import com.hshh.model.entity.ModelDefine; import com.hshh.model.entity.ModelDefine;
import com.hshh.model.service.FormFieldConfigService; import com.hshh.model.service.FormFieldConfigService;
import com.hshh.model.service.ModelDefineService; import com.hshh.model.service.ModelDefineService;
import com.hshh.system.base.entity.DictItem;
import com.hshh.system.base.service.DictItemService;
import com.hshh.system.common.bean.ErrorField; import com.hshh.system.common.bean.ErrorField;
import com.hshh.system.common.bean.FieldType; import com.hshh.system.common.bean.FieldType;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional; import java.util.Optional;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -36,11 +39,14 @@ public class DataRecordServiceImpl implements DataRecordService {
*/ */
@Resource @Resource
private FormFieldConfigService formFieldConfigService; private FormFieldConfigService formFieldConfigService;
@Resource
private DictItemService dictItemService;
//最大排序号 //最大排序号
private static final int maxOrder = 999; private static final int maxOrder = 999;
@Override @Override
public String html(Integer modelId) { public String html(Integer modelId) {
Map<Integer, List<DictItem>> dictMap = dictItemService.dictItemMap();
//首先获取模型定义中,form中的字段显示方式,每行显示几个字段 //首先获取模型定义中,form中的字段显示方式,每行显示几个字段
ModelDefine modelDefine = modelDefineService.getById(modelId); ModelDefine modelDefine = modelDefineService.getById(modelId);
if (modelDefine == null) { if (modelDefine == null) {
@ -63,7 +69,7 @@ public class DataRecordServiceImpl implements DataRecordService {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append("<div class=\"row\">"); sb.append("<div class=\"row\">");
fieldList.forEach(field -> { fieldList.forEach(field -> {
handleField(field, sb, divClass); handleField(field, sb, divClass, dictMap);
}); });
sb.append("</div>"); sb.append("</div>");
@ -77,7 +83,8 @@ public class DataRecordServiceImpl implements DataRecordService {
* @param sb html字符容器 * @param sb html字符容器
* @param divClass 每个字段占用的格数 ,在不同的屏幕下 * @param divClass 每个字段占用的格数 ,在不同的屏幕下
*/ */
private void handleField(FormFieldConfig field, StringBuffer sb, String divClass) { private void handleField(FormFieldConfig field, StringBuffer sb, String divClass,
Map<Integer, List<DictItem>> dictMap) {
String unit = ""; String unit = "";
if (StringUtils.isNotBlank(field.getFieldUnit())) { if (StringUtils.isNotBlank(field.getFieldUnit())) {
unit = "(" + field.getFieldUnit() + ")"; unit = "(" + field.getFieldUnit() + ")";
@ -90,7 +97,7 @@ public class DataRecordServiceImpl implements DataRecordService {
sb.append("<label class=\"form-label ").append(required).append("\">") sb.append("<label class=\"form-label ").append(required).append("\">")
.append(field.getFieldLabel()).append(unit).append("</label>"); .append(field.getFieldLabel()).append(unit).append("</label>");
//输入域增加 //输入域增加
handleInputType(field, sb); handleInputType(field, sb, dictMap);
//验证div //验证div
sb.append("<div class=\"invalid-feedback\" id=\"").append(field.getFieldId()) sb.append("<div class=\"invalid-feedback\" id=\"").append(field.getFieldId())
.append("_error_tip\"></div>"); .append("_error_tip\"></div>");
@ -100,7 +107,8 @@ public class DataRecordServiceImpl implements DataRecordService {
sb.append("</div>"); sb.append("</div>");
} }
private void handleInputType(FormFieldConfig field, StringBuffer sb) { private void handleInputType(FormFieldConfig field, StringBuffer sb,
Map<Integer, List<DictItem>> dictMap) {
if (field.getFieldType() == null) { if (field.getFieldType() == null) {
field.setFieldType("TEXT"); field.setFieldType("TEXT");
} }
@ -132,6 +140,19 @@ public class DataRecordServiceImpl implements DataRecordService {
.append(field.getFieldId()) .append(field.getFieldId())
.append("\" class=\"form-control\" autocomplete=\"off\" >"); .append("\" class=\"form-control\" autocomplete=\"off\" >");
break; break;
case SELECT:
sb.append(" <select class=\"form-select\" name=\"")
.append(field.getFieldName()).append("\" id=\"").append(field.getFieldId())
.append("\">");
List<DictItem> itemList = dictMap.get(field.getFieldOptionsId());
itemList.forEach(item -> {
sb.append("<option value=\"").append(item.getCode()).append("\">")
.append(item.getNameCn())
.append("</option>");
});
sb.append("</select>");
break;
default: default:
break; break;
} }
@ -151,8 +172,5 @@ public class DataRecordServiceImpl implements DataRecordService {
return errorFieldList; return errorFieldList;
} }
@Override
public void deleteFromByModelId(Integer id) {
}
} }

View File

@ -6,6 +6,7 @@ import com.hshh.evaluation.bean.ReportIndicatorNodeData;
import com.hshh.evaluation.entity.EvaluationIndicatorResult; import com.hshh.evaluation.entity.EvaluationIndicatorResult;
import com.hshh.evaluation.entity.EvaluationRootResult; import com.hshh.evaluation.entity.EvaluationRootResult;
import com.hshh.indicator.entity.IndicatorTopLevel; import com.hshh.indicator.entity.IndicatorTopLevel;
import com.hshh.system.Global;
import com.hshh.system.common.bean.BaseController; import com.hshh.system.common.bean.BaseController;
import com.hshh.system.common.enums.LevelEnum; import com.hshh.system.common.enums.LevelEnum;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -46,16 +47,17 @@ public class AssistantEvaluationProjectController extends BaseController {
} }
protected String getClosestLevel(List<IndicatorTopLevel> levelList, int targetScore) { protected String getClosestLevel(List<IndicatorTopLevel> levelList, int targetScore) {
IndicatorTopLevel closest = null; levelList.sort((a, b) -> Integer.compare(Integer.parseInt(b.getLowValue()),
int minDiff = Integer.MAX_VALUE; Integer.parseInt(a.getLowValue())));
for (IndicatorTopLevel item : levelList) {
int diff = Math.abs(targetScore - (int) Double.parseDouble(item.getGrade())); String levelName = levelList.get(levelList.size() - 1).getLevelName();
if (diff < minDiff) { for (IndicatorTopLevel level : levelList) {
minDiff = diff; if (targetScore >= Integer.parseInt(level.getLowValue())) {
closest = item; levelName = level.getLevelName();
break;
} }
} }
return closest != null ? closest.getLevelName() : null; return levelName;
} }
//获取优良率 //获取优良率
@ -76,13 +78,14 @@ public class AssistantEvaluationProjectController extends BaseController {
if (levelList.isEmpty()) { if (levelList.isEmpty()) {
return; return;
} }
levelList.sort((a, b) -> Integer.compare(Integer.parseInt(b.getGrade()), Integer.parseInt(a.getGrade()))); levelList.sort(
(a, b) -> Integer.compare(Integer.parseInt(b.getGrade()), Integer.parseInt(a.getGrade())));
rootResult.setLevelName(levelList.get(levelList.size() - 1).getLevelName()); rootResult.setLevelName(levelList.get(levelList.size() - 1).getLevelName());
for (IndicatorTopLevel indicatorTopLevel : levelList) { for (IndicatorTopLevel indicatorTopLevel : levelList) {
if (Double.parseDouble(rootResult.getFinalScore()) >= Double.parseDouble( if (Double.parseDouble(rootResult.getFinalScore()) >= Double.parseDouble(
indicatorTopLevel.getGrade())) { indicatorTopLevel.getLowValue())) {
rootResult.setLevelName(indicatorTopLevel.getLevelName()); rootResult.setLevelName(indicatorTopLevel.getLevelName());
break; break;
} }
@ -113,14 +116,14 @@ public class AssistantEvaluationProjectController extends BaseController {
reportIndicatorNodeData.setName(indicatorResult.getIndicatorName()); reportIndicatorNodeData.setName(indicatorResult.getIndicatorName());
reportIndicatorNodeData.setLevel(indicatorResult.getLevel()); reportIndicatorNodeData.setLevel(indicatorResult.getLevel());
reportIndicatorNodeData.setScore( reportIndicatorNodeData.setScore(
new BigDecimal(indicatorResult.getFinalScore()).setScale(2, RoundingMode.HALF_UP) new BigDecimal(indicatorResult.getFinalScore()).setScale(Global.scale, RoundingMode.HALF_UP)
.doubleValue()); .doubleValue());
Map<String, Double> membershipScoreMap = new HashMap<>(); Map<String, Double> membershipScoreMap = new HashMap<>();
Map<String, Double> originalMap = membershipScoreMap(indicatorResult.getMemberShipScore()); Map<String, Double> originalMap = membershipScoreMap(indicatorResult.getMemberShipScore());
originalMap.forEach((k, v) -> { originalMap.forEach((k, v) -> {
membershipScoreMap.put(LevelEnum.getCode(k), membershipScoreMap.put(LevelEnum.getCode(k),
BigDecimal.valueOf(v * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); BigDecimal.valueOf(v * 100).setScale(Global.scale, RoundingMode.HALF_UP).doubleValue());
}); });
reportIndicatorNodeData.setMembershipDist(membershipScoreMap); reportIndicatorNodeData.setMembershipDist(membershipScoreMap);
reportIndicatorNodeData.setEvaluation( reportIndicatorNodeData.setEvaluation(
@ -139,7 +142,7 @@ public class AssistantEvaluationProjectController extends BaseController {
BarData barData = new BarData(); BarData barData = new BarData();
barData.setName(indicatorResult.getIndicatorName()); barData.setName(indicatorResult.getIndicatorName());
barData.setScore( barData.setScore(
new BigDecimal(indicatorResult.getFinalScore()).setScale(2, RoundingMode.HALF_UP) new BigDecimal(indicatorResult.getFinalScore()).setScale(Global.scale, RoundingMode.HALF_UP)
.doubleValue()); .doubleValue());
resultList.add(barData); resultList.add(barData);
}); });

View File

@ -21,10 +21,14 @@ import com.hshh.indicator.entity.Indicator;
import com.hshh.indicator.entity.IndicatorTopLevel; import com.hshh.indicator.entity.IndicatorTopLevel;
import com.hshh.indicator.service.IndicatorService; import com.hshh.indicator.service.IndicatorService;
import com.hshh.indicator.service.IndicatorTopLevelService; import com.hshh.indicator.service.IndicatorTopLevelService;
import com.hshh.model.entity.FormFieldConfig;
import com.hshh.model.entity.FormValue; import com.hshh.model.entity.FormValue;
import com.hshh.model.service.FormFieldConfigService; import com.hshh.model.service.FormFieldConfigService;
import com.hshh.model.service.FormValueService; import com.hshh.model.service.FormValueService;
import com.hshh.system.Global;
import com.hshh.system.annotation.LogOperation; import com.hshh.system.annotation.LogOperation;
import com.hshh.system.base.entity.DictItem;
import com.hshh.system.base.service.DictItemService;
import com.hshh.system.common.bean.OperateResult; import com.hshh.system.common.bean.OperateResult;
import com.hshh.system.common.bean.PaginationBean; import com.hshh.system.common.bean.PaginationBean;
import com.hshh.system.common.enums.ErrorCode; import com.hshh.system.common.enums.ErrorCode;
@ -113,7 +117,8 @@ public class EvaluationProjectController extends AssistantEvaluationProjectContr
private IndicatorTopLevelService topLevelService; private IndicatorTopLevelService topLevelService;
@Resource @Resource
private EvaluationIndicatorResultService evaluationIndicatorResultService; private EvaluationIndicatorResultService evaluationIndicatorResultService;
@Resource
private DictItemService dictItemService;
/** /**
* 默认页. * 默认页.
* *
@ -222,7 +227,7 @@ public class EvaluationProjectController extends AssistantEvaluationProjectContr
@GetMapping("/database") @GetMapping("/database")
public String databasePage(PaginationBean request, Model model, public String databasePage(PaginationBean request, Model model,
@RequestParam Map<String, String> params) { @RequestParam Map<String, String> params) {
Map<Integer, List<DictItem>> dictItemMap = dictItemService.dictItemMap();
//获取基础设施ID //获取基础设施ID
Long modelId = evaluationProjectService.selectModelIdByProjectId( Long modelId = evaluationProjectService.selectModelIdByProjectId(
params.get("projectId") == null ? 0 : Integer.parseInt(params.get("projectId"))); params.get("projectId") == null ? 0 : Integer.parseInt(params.get("projectId")));
@ -235,7 +240,12 @@ public class EvaluationProjectController extends AssistantEvaluationProjectContr
addDatasourceModelAttribute(request, model, params); addDatasourceModelAttribute(request, model, params);
//获取表头 //获取表头
Map<String, String> headerMap = formFieldConfigService.getHeaderMap(modelId.intValue()); Map<String, FormFieldConfig> headerFieldMap = formFieldConfigService.getHeaderMap(
modelId.intValue());
Map<String, String> headerMap = new LinkedHashMap<>();
headerFieldMap.forEach((k, v) -> {
headerMap.put(k, v.getFieldLabel());
});
model.addAttribute("headerMap", headerMap); model.addAttribute("headerMap", headerMap);
//查询数据 //查询数据
//替换为modelId查询 //替换为modelId查询
@ -245,7 +255,7 @@ public class EvaluationProjectController extends AssistantEvaluationProjectContr
List<Map<String, Object>> listMap = new ArrayList<>(); List<Map<String, Object>> listMap = new ArrayList<>();
formDataList.forEach(formData -> { formDataList.forEach(formData -> {
listMap.add(formData.toMap()); //转为map对象放入listMap中 listMap.add(formData.toMap(headerFieldMap, dictItemMap)); //转为map对象放入listMap中
}); });
Long total = formValueService.count(request); Long total = formValueService.count(request);
@ -446,7 +456,9 @@ public class EvaluationProjectController extends AssistantEvaluationProjectContr
//各维度得分对比 //各维度得分对比
String membership = rootResult.getMembershipScore(); String membership = rootResult.getMembershipScore();
//获取各个等级的隶属度key=,,,; value为实际隶属度
Map<String, Double> membershipMap = membershipScoreMap(membership); Map<String, Double> membershipMap = membershipScoreMap(membership);
StringBuilder replaceMemberShipBuilder = new StringBuilder(); StringBuilder replaceMemberShipBuilder = new StringBuilder();
levelList.forEach(level -> { levelList.forEach(level -> {
if (membershipMap.get(level.getLevelName()) != null) { if (membershipMap.get(level.getLevelName()) != null) {
@ -454,7 +466,7 @@ public class EvaluationProjectController extends AssistantEvaluationProjectContr
.append(membershipMap.get(level.getLevelName())).append(";"); .append(membershipMap.get(level.getLevelName())).append(";");
; ;
level.setActualValue(new BigDecimal(level.getGrade()).multiply( level.setActualValue(new BigDecimal(level.getGrade()).multiply(
new BigDecimal(membershipMap.get(level.getLevelName()))).setScale(1, new BigDecimal(membershipMap.get(level.getLevelName()))).setScale(Global.scale,
RoundingMode.HALF_UP).doubleValue()); RoundingMode.HALF_UP).doubleValue());
} }
}); });

View File

@ -361,7 +361,7 @@ public class CoreEvaluationServiceImpl implements CoreEvaluationService {
topLevelList.forEach(topLevel -> { topLevelList.forEach(topLevel -> {
EvaluationLevel evaluationLevel = new EvaluationLevel(topLevel.getLevelName(), EvaluationLevel evaluationLevel = new EvaluationLevel(topLevel.getLevelName(),
Double.parseDouble(topLevel.getGrade()), Double.parseDouble(topLevel.getGrade()),
topLevel.getEqualValue() == null ? "" : topLevel.getEqualValue()); topLevel.getLowValue() == null ? "" : topLevel.getLowValue());
evaluationLevels.add(evaluationLevel); evaluationLevels.add(evaluationLevel);
}); });
return new GlobalEvaluationConfig(evaluationLevels); return new GlobalEvaluationConfig(evaluationLevels);

View File

@ -7,6 +7,7 @@ import com.hshh.evaluation.entity.EvaluationRootResult;
import com.hshh.evaluation.mapper.EvaluationRootResultMapper; import com.hshh.evaluation.mapper.EvaluationRootResultMapper;
import com.hshh.evaluation.service.EvaluationIndicatorResultService; import com.hshh.evaluation.service.EvaluationIndicatorResultService;
import com.hshh.evaluation.service.EvaluationRootResultService; import com.hshh.evaluation.service.EvaluationRootResultService;
import com.hshh.system.Global;
import com.hshh.system.algorithm.fuzzy.IndicatorNode; import com.hshh.system.algorithm.fuzzy.IndicatorNode;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
@ -53,7 +54,7 @@ public class EvaluationRootResultServiceImpl extends
indicatorNode.setScore(0d); indicatorNode.setScore(0d);
} }
rootResult.setFinalScore( rootResult.setFinalScore(
new BigDecimal(indicatorNode.getScore()).setScale(1, RoundingMode.UP).toPlainString()); new BigDecimal(indicatorNode.getScore()).setScale(Global.scale, RoundingMode.UP).toPlainString());
StringBuilder membershipBuilder = new StringBuilder(); StringBuilder membershipBuilder = new StringBuilder();
indicatorNode.getMembershipDegrees().forEach((k, v) -> { indicatorNode.getMembershipDegrees().forEach((k, v) -> {
membershipBuilder.append(k).append(":").append(String.format(doubleFormat, v)).append(";"); membershipBuilder.append(k).append(":").append(String.format(doubleFormat, v)).append(";");

View File

@ -39,5 +39,6 @@ public class IndicatorTopLevel implements Serializable {
@TableField(exist = false) @TableField(exist = false)
private double actualValue; private double actualValue;
private String equalValue; //等级判断最低分
private String lowValue;
} }

View File

@ -6,7 +6,6 @@ import com.hshh.model.service.FormFieldConfigService;
import com.hshh.model.service.ModelDefineService; import com.hshh.model.service.ModelDefineService;
import com.hshh.system.base.entity.DictItem; import com.hshh.system.base.entity.DictItem;
import com.hshh.system.base.entity.DictType; import com.hshh.system.base.entity.DictType;
import com.hshh.system.base.entity.TableRelations;
import com.hshh.system.base.service.DictItemService; import com.hshh.system.base.service.DictItemService;
import com.hshh.system.base.service.DictTypeService; import com.hshh.system.base.service.DictTypeService;
import com.hshh.system.base.service.TableRelationsService; import com.hshh.system.base.service.TableRelationsService;
@ -19,6 +18,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.Valid; import javax.validation.Valid;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -109,6 +109,13 @@ public class ModelDefineController extends BaseController {
} }
} }
Map<Integer, DictType> dictTypeMap = dictTypeService.dictTypeMap();
fieldList.forEach(field -> {
if (field.getFieldOptionsId() != null) {
field.setFieldOptionsName(dictTypeMap.get(field.getFieldOptionsId()) == null ? ""
: dictTypeMap.get(field.getFieldOptionsId()).getDictTypeName());
}
});
//当前中选中的字段列表 //当前中选中的字段列表
model.addAttribute("fieldList", fieldList); model.addAttribute("fieldList", fieldList);
//模型列表 //模型列表
@ -213,6 +220,10 @@ public class ModelDefineController extends BaseController {
if (bindResult.hasErrors()) { if (bindResult.hasErrors()) {
return errorsInputHandle(bindResult); return errorsInputHandle(bindResult);
} }
//当类型为不为select时,下拉选项无效
if (!"SELECT".equals(config.getFieldType())) {
config.setFieldOptionsId(null);
}
//验证字段是否有重复同一个模型下 //验证字段是否有重复同一个模型下
List<FormFieldConfig> exitList = formFieldConfigService.getFormFieldConfigByLabelOrNameOrId( List<FormFieldConfig> exitList = formFieldConfigService.getFormFieldConfigByLabelOrNameOrId(
config.getDataModelId(), config.getDataModelId(),
@ -222,6 +233,7 @@ public class ModelDefineController extends BaseController {
return OperateResult.error(null, ErrorMessage.NAME_OR_CODE_EXIT.getMessage(), return OperateResult.error(null, ErrorMessage.NAME_OR_CODE_EXIT.getMessage(),
ErrorCode.BUSINESS_ERROR.getCode()); ErrorCode.BUSINESS_ERROR.getCode());
} }
formFieldConfigService.save(config); formFieldConfigService.save(config);
} else { } else {
if (exitList != null && !exitList.isEmpty()) { if (exitList != null && !exitList.isEmpty()) {

View File

@ -49,6 +49,8 @@ public class FormFieldConfig implements Serializable {
private Integer fieldOptionsId; private Integer fieldOptionsId;
@TableField(exist = false)
private String fieldOptionsName;
private String fieldPlaceholder; private String fieldPlaceholder;

View File

@ -5,9 +5,12 @@ import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.hshh.system.base.entity.DictItem;
import com.hshh.system.common.bean.BaseBean; import com.hshh.system.common.bean.BaseBean;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import lombok.Data; import lombok.Data;
/** /**
@ -38,11 +41,25 @@ public class FormValue extends BaseBean {
* *
* @return map键值对 * @return map键值对
*/ */
public Map<String, Object> toMap() { public Map<String, Object> toMap(Map<String, FormFieldConfig> formFieldConfigMap,
Map<Integer, List<DictItem>> dictMap) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("id", id); map.put("id", id);
map.put("seq", getSeq()); map.put("seq", getSeq());
JSONObject jsonObj = JSON.parseObject(modelData, JSONObject.class); JSONObject jsonObj = JSON.parseObject(modelData, JSONObject.class);
jsonObj.forEach((key, value) -> {
if (formFieldConfigMap.get(key) != null && "SELECT".equals(
formFieldConfigMap.get(key).getFieldType())) {
List<DictItem> itemList = dictMap.get(
formFieldConfigMap.get(key).getFieldOptionsId() == null ? 0
: formFieldConfigMap.get(key).getFieldOptionsId());
Map<String, DictItem> itemMap = itemList.stream()
.collect(Collectors.toMap(DictItem::getCode, a -> a));
jsonObj.put(key, itemMap.get(value.toString()).getNameCn());
}
});
map.putAll(jsonObj); map.putAll(jsonObj);
return map; return map;
} }

View File

@ -40,6 +40,6 @@ public interface FormFieldConfigService extends IService<FormFieldConfig> {
* @param modelId 基础设施ID * @param modelId 基础设施ID
* @return 字段map * @return 字段map
*/ */
Map<String, String> getHeaderMap(Integer modelId); Map<String, FormFieldConfig> getHeaderMap(Integer modelId);
void deleteByModelId(Integer modelId); void deleteByModelId(Integer modelId);
} }

View File

@ -40,8 +40,8 @@ public class FormFieldConfigServiceImpl extends
} }
@Override @Override
public Map<String, String> getHeaderMap(Integer modelId) { public Map<String, FormFieldConfig> getHeaderMap(Integer modelId) {
Map<String, String> headerMap = new LinkedHashMap<>(); Map<String, FormFieldConfig> headerMap = new LinkedHashMap<>();
List<FormFieldConfig> list = getFormFieldConfigByModelId(modelId); List<FormFieldConfig> list = getFormFieldConfigByModelId(modelId);
list.sort((a, b) -> { list.sort((a, b) -> {
if (a.getSortOrder() == null) { if (a.getSortOrder() == null) {
@ -53,7 +53,7 @@ public class FormFieldConfigServiceImpl extends
return a.getSortOrder().compareTo(b.getSortOrder()); return a.getSortOrder().compareTo(b.getSortOrder());
}); });
list.forEach(formFieldConfig -> { list.forEach(formFieldConfig -> {
headerMap.put(formFieldConfig.getFieldName(), formFieldConfig.getFieldLabel()); headerMap.put(formFieldConfig.getFieldName(), formFieldConfig);
}); });
return headerMap; return headerMap;
} }

View File

@ -13,14 +13,14 @@ spring:
thymeleaf: thymeleaf:
cache: false cache: false
datasource: datasource:
url: jdbc:dm://127.0.0.1:5236/MANAGER # url: jdbc:dm://127.0.0.1:5236/MANAGER
username: SYSDBA # username: SYSDBA
password: SYSDBA001 # password: SYSDBA001
driver-class-name: dm.jdbc.driver.DmDriver # driver-class-name: dm.jdbc.driver.DmDriver
# url: jdbc:mysql://localhost:3306/manager?allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC url: jdbc:mysql://localhost:3306/manager?allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC
# username: root username: root
# password: 123456 password: 123456
# driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
hikari: hikari:
minimum-idle: 5 minimum-idle: 5
maximum-pool-size: 20 maximum-pool-size: 20

View File

@ -2,22 +2,22 @@ indicator:
default: default:
levels: levels:
- levelName: - levelName:
grade: 90 grade: 95
levelOrder: 1 levelOrder: 1
equalValue: lowValue: 90
- levelName: - levelName:
grade: 80 grade: 85
levelOrder: 2 levelOrder: 2
equalValue: lowValue: 80
- levelName: - levelName:
grade: 70 grade: 75
levelOrder: 3 levelOrder: 3
equalValue: lowValue: 70
- levelName: - levelName:
grade: 60 grade: 65
levelOrder: 4 levelOrder: 4
equalValue: lowValue: 60
function: function:
membershipFunc: TRAP_TRI membershipFunc: TRAP_TRI
softEdgeS: 0.10 softEdgeS: 0.10

View File

@ -371,6 +371,25 @@
} }
} }
table {
border-collapse: collapse;
min-width: 1200px; /* 比容器宽,才会滚动 */
width: 100%;
}
/* 固定最后一列 */
th:last-child,
td:last-child {
position: sticky;
right: 0;
background: #f7fafc;
z-index: 2;
}
/* 可选:加个阴影效果,体验更好 */
th:last-child,
td:last-child {
box-shadow: -2px 0 6px -2px #8882;
}
</style> </style>
</head> </head>
<body> <body>

View File

@ -13,7 +13,7 @@
</div> </div>
<div class="col-md-6 "> <div class="col-md-6 ">
<div class="mb-3"> <div class="mb-3">
<label class="form-label required">英文名称</label> <label class="form-label required" for="fieldName">英文名称</label>
<input type="text" name="fieldName" id="fieldName" class="form-control" <input type="text" name="fieldName" id="fieldName" class="form-control"
placeholder="name 必须是英文" autocomplete="off" placeholder="name 必须是英文" autocomplete="off"
value=""> value="">
@ -22,29 +22,14 @@
</div> </div>
<div class="col-md-6 "> <div class="col-md-6 ">
<div class="mb-3"> <div class="mb-3">
<label class="form-label">必填</label> <label class="form-label" for="isRequired">必填</label>
<select name="isRequired" id="isRequired" class="form-control"> <select name="isRequired" id="isRequired" class="form-control">
<option value="0">非必填</option> <option value="0">非必填</option>
<option value="1">必填</option> <option value="1">必填</option>
</select> </select>
</div> </div>
</div> </div>
<!-- <div class="col-md-6 ">-->
<!-- <div class="mb-3">-->
<!-- <label class="form-label">默认值</label>-->
<!-- <input type="text" name="fieldDefaultValue" id="fieldDefaultValue" class="form-control"-->
<!-- placeholder="字段默认值" value="" autocomplete="off">-->
<!-- <div class="invalid-feedback" id="fieldDefaultValue_error_tip"></div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="col-md-6 ">-->
<!-- <div class="mb-3">-->
<!-- <label class="form-label">输入提示</label>-->
<!-- <input type="text" name="fieldPlaceholder" id="fieldPlaceholder" class="form-control"-->
<!-- placeholder="输入提示" value="" autocomplete="off">-->
<!-- <div class="invalid-feedback" id="fieldPlaceholder_error_tip"></div>-->
<!-- </div>-->
<!-- </div>-->
<div class="col-md-6 "> <div class="col-md-6 ">
<div class="mb-3"> <div class="mb-3">
<label class="form-label" for="fieldUnit">单位</label> <label class="form-label" for="fieldUnit">单位</label>
@ -59,137 +44,64 @@
</div> </div>
<div class="col-md-6 "> <div class="col-md-6 ">
<div class="mb-3"> <div class="mb-3">
<label class="form-label">类型</label> <label class="form-label" for="fieldType">类型</label>
<select name="fieldType" id="fieldType" class="form-control"> <select name="fieldType" id="fieldType" class="form-control" onchange="showDiv(this)">
<option value="TEXT">单行文本输入</option> <option value="TEXT">单行文本输入</option>
<!-- <option value="TEXTAREA">多行文本输入</option>-->
<!-- <option value="PASSWORD">密码输入</option>-->
<option value="NUMBER">数字输入</option> <option value="NUMBER">数字输入</option>
<!-- <option value="EMAIL">邮箱输入</option>-->
<!-- <option value="SELECT">下拉选择</option>--> <option value="SELECT">下拉选择</option>
<!-- <option value="RADIO">单选框</option>--> <option value="DATE">日期选择</option>
<!-- <option value="CHECKBOX">多选框</option>--> <option value="DATETIME">日期时间选择</option>
<option value="DATE">日期选择</option> <option value="TIME">时间选择</option>
<option value="DATETIME">日期时间选择</option>
<option value="TIME">时间选择</option>
<!-- <option value="FILE">文件上传</option>-->
<!-- <option value="IMAGE">图片上传</option>-->
<!-- <option value="URL">链接输入</option>-->
<!-- <option value="COLOR">颜色选择器</option>-->
<!-- <option value="TEL">电话输入</option>-->
<!-- <option value="HIDDEN">隐藏字段</option>-->
</select> </select>
</div> </div>
</div> </div>
<!-- <div class="col-md-6 ">--> <div class="col-md-6 " style="display: none !important;" id="selectField-div">
<!-- <div class="mb-3">--> <div class="mb-3">
<!-- <label class="form-label">码表选项</label>--> <label class="form-label">码表选项</label>
<!-- <select name="fieldOptionsId" id="fieldOptionsId" class="form-control">--> <select name="fieldOptionsId" id="fieldOptionsId" class="form-control">
<!-- <option value="0">无</option>--> <option value="0"></option>
<!-- <option th:each="type:${typeList}" th:text="${type.dictTypeName}"--> <option th:each="type:${typeList}" th:text="${type.dictTypeName}"
<!-- th:value="${type.id}"></option>--> th:value="${type.id}"></option>
<!-- </select>--> </select>
<!-- </div>--> </div>
<!-- </div>--> </div>
<!-- <div class="col-md-6 ">-->
<!-- <div class="mb-3">-->
<!-- <label class="form-label">只读</label>-->
<!-- <select name="readonlyFlag" id="readonlyFlag" class="form-control">-->
<!-- <option value="0">非只读</option>-->
<!-- <option value="1">只读</option>-->
<!-- </select>-->
<!-- </div>--> <div class="col-md-6 " id="textField-min-div">
<!-- </div>--> <div class="mb-3">
<!-- <div class="col-md-6 ">--> <label class="form-label">长度最小值(文本型)</label>
<!-- <div class="mb-3">--> <input type="number" name="fieldMinSize" id="fieldMinSize" class="form-control"
<!-- <label class="form-label">禁用</label>--> placeholder="字段长度最小值" value="" autocomplete="off">
<!-- <select name="disabledFlag" id="disabledFlag" class="form-control">--> <div class="invalid-feedback" id="fieldMinSize_error_tip"></div>
<!-- <option value="0">非禁用</option>--> </div>
<!-- <option value="1">禁用</option>--> </div>
<!-- </select>--> <div class="col-md-6 " id="textField-max-div">
<div class="mb-3">
<!-- </div>--> <label class="form-label">长度最大值(文本型)</label>
<!-- </div>--> <input type="number" name="fieldMaxSize" id="fieldMaxSize" class="form-control"
<!-- <div class="col-md-6 ">--> placeholder="字段长度最大值" value="" autocomplete="off">
<!-- <div class="mb-3">--> <div class="invalid-feedback" id="fieldMaxSize_error_tip"></div>
<!-- <label class="form-label">自动完成</label>--> </div>
<!-- <select name="autocompleteFlag" id="autocompleteFlag" class="form-control">--> </div>
<!-- <option value="0">非</option>--> <div class="col-md-6 " id="numberField-min-div" style="display: none !important;">
<!-- <option value="1">是</option>--> <div class="mb-3">
<!-- </select>--> <label class="form-label">最小值(数值型)</label>
<input type="number" name="fieldMinVal" id="fieldMinVal" class="form-control"
<!-- </div>--> placeholder="字段最小值(数值型)" value="" autocomplete="off">
<!-- </div>--> <div class="invalid-feedback" id="fieldMinVal_error_tip"></div>
<!-- <div class="col-md-6 ">--> </div>
<!-- <div class="mb-3">--> </div>
<!-- <label class="form-label">显示</label>--> <div class="col-md-6 " id="numberField-max-div" style="display: none !important;">
<!-- <select name="hiddenFlag" id="hiddenFlag" class="form-control">--> <div class="mb-3">
<!-- <option value="0">显示</option>--> <label class="form-label">最大值(数值型)</label>
<!-- <option value="1">不显示</option>--> <input type="number" name="fieldMaxVal" id="fieldMaxVal" class="form-control"
<!-- </select>--> placeholder="字段最大值(数值型)" value="" autocomplete="off">
<!-- </div>--> <div class="invalid-feedback" id="fieldMaxVal_error_tip"></div>
<!-- </div>--> </div>
</div>
<!-- <div class="col-md-6 ">-->
<!-- <div class="mb-3">-->
<!-- <label class="form-label">format函数</label>-->
<!-- <input type="text" name="formatFunc" id="formatFunc" class="form-control"-->
<!-- placeholder="format函数" value="" autocomplete="off">-->
<!-- <div class="invalid-feedback" id="formatFunc_error_tip"></div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="col-md-6 ">-->
<!-- <div class="mb-3">-->
<!-- <label class="form-label">正则表达式</label>-->
<!-- <input type="text" name="validateRule" id="validateRule" class="form-control"-->
<!-- placeholder="正则表达式" value="" autocomplete="off">-->
<!-- <div class="invalid-feedback" id="validateRule_error_tip"></div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="col-md-6 ">-->
<!-- <div class="mb-3">-->
<!-- <label class="form-label">正则表达提示</label>-->
<!-- <input type="text" name="validateRuleMessage" id="validateRuleMessage" class="form-control"-->
<!-- placeholder="正则表达提示" value="" autocomplete="off">-->
<!-- <div class="invalid-feedback" id="validateRuleMessage_error_tip"></div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="col-md-6 ">-->
<!-- <div class="mb-3">-->
<!-- <label class="form-label">长度最小值(文本型)</label>-->
<!-- <input type="number" name="fieldMinSize" id="fieldMinSize" class="form-control"-->
<!-- placeholder="字段长度最小值" value="" autocomplete="off">-->
<!-- <div class="invalid-feedback" id="fieldMinSize_error_tip"></div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="col-md-6 ">-->
<!-- <div class="mb-3">-->
<!-- <label class="form-label">长度最大值(文本型)</label>-->
<!-- <input type="number" name="fieldMaxSize" id="fieldMaxSize" class="form-control"-->
<!-- placeholder="字段长度最大值" value="" autocomplete="off">-->
<!-- <div class="invalid-feedback" id="fieldMaxSize_error_tip"></div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="col-md-6 ">-->
<!-- <div class="mb-3">-->
<!-- <label class="form-label">最小值(数值型)</label>-->
<!-- <input type="number" name="fieldMinVal" id="fieldMinVal" class="form-control"-->
<!-- placeholder="字段最小值(数值型)" value="" autocomplete="off">-->
<!-- <div class="invalid-feedback" id="fieldMinVal_error_tip"></div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="col-md-6 ">-->
<!-- <div class="mb-3">-->
<!-- <label class="form-label">最大值(数值型)</label>-->
<!-- <input type="number" name="fieldMaxVal" id="fieldMaxVal" class="form-control"-->
<!-- placeholder="字段最大值(数值型)" value="" autocomplete="off">-->
<!-- <div class="invalid-feedback" id="fieldMaxVal_error_tip"></div>-->
<!-- </div>-->
<!-- </div>-->
<div class="col-md-6 "> <div class="col-md-6 ">
<div class="mb-3"> <div class="mb-3">
<label class="form-label">显示顺序</label> <label class="form-label">显示顺序</label>
@ -199,3 +111,4 @@
</div> </div>
</div> </div>
</div> </div>

View File

@ -7,6 +7,7 @@
padding-bottom: 0.5rem; padding-bottom: 0.5rem;
margin-bottom: 0; margin-bottom: 0;
} }
.card-body.list-area { .card-body.list-area {
border-radius: 0 0 0.5rem 0.5rem; border-radius: 0 0 0.5rem 0.5rem;
padding-top: 0.5rem; padding-top: 0.5rem;
@ -34,7 +35,7 @@
增加设施 增加设施
</a> </a>
</div> </div>
<div class="card-body search-bar" > <div class="card-body search-bar">
<div class="input-icon "> <div class="input-icon ">
<input type="text" value="" class="form-control" placeholder="Search…"> <input type="text" value="" class="form-control" placeholder="Search…">
<span class="input-icon-addon"> <span class="input-icon-addon">
@ -112,7 +113,7 @@
</div> </div>
<div class="card-body p-0"> <div class="card-body p-0">
<div class="table-responsive"> <div class="table-responsive">
<table class="table card-table table-vcenter text-nowrap datatable"> <table class="table card-table table-vcenter text-nowrap datatable ">
<thead> <thead>
<tr> <tr>
<th class="w-1">No. <th class="w-1">No.
@ -128,21 +129,21 @@
<th>标签</th> <th>标签</th>
<th>名称</th> <th>名称</th>
<th>默认值</th>
<th>类型</th> <th>类型</th>
<th>可选项</th> <th>可选项</th>
<th>输入提示</th>
<th>必填标志</th> <th>必填标志</th>
<!-- <th>只读标志</th>--> <!-- <th>只读标志</th>-->
<!-- <th>禁用标志</th>--> <!-- <th>禁用标志</th>-->
<!-- <th>自动完成标志</th>--> <!-- <th>自动完成标志</th>-->
<!-- <th>最大长度</th>--> <!-- <th>最大长度</th>-->
<!-- <th>最小长度</th>--> <!-- <th>最小长度</th>-->
<!-- <th>最大值</th>--> <!-- <th>最大值</th>-->
<!-- <th>最小值</th>--> <!-- <th>最小值</th>-->
<!-- <th>正则表达式</th>--> <!-- <th>正则表达式</th>-->
<!-- <th>正则验证消息</th>--> <!-- <th>正则验证消息</th>-->
<!-- <th>format函数</th>--> <!-- <th>format函数</th>-->
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
@ -152,21 +153,21 @@
<td th:text="${field.getFieldLabel()}"></td> <td th:text="${field.getFieldLabel()}"></td>
<td th:text="${field.getFieldName()}"></td> <td th:text="${field.getFieldName()}"></td>
<td th:text="${field.getFieldDefaultValue()}"></td>
<td th:text="${field.getFieldType()}"></td> <td th:text="${field.getFieldType()}"></td>
<td th:text="${field.getFieldOptionsId()}"></td> <td th:text="${field.getFieldOptionsName()}"></td>
<td th:text="${field.getFieldPlaceholder()}"></td>
<td th:text="${field.getIsRequired() == 1 ? 'Y' : 'N'}"></td> <td th:text="${field.getIsRequired() == 1 ? 'Y' : 'N'}"></td>
<!-- <td th:text="${field.getReadonlyFlag()==1?'Y':'N'}"></td>--> <!-- <td th:text="${field.getReadonlyFlag()==1?'Y':'N'}"></td>-->
<!-- <td th:text="${field.getDisabledFlag()==1?'Y':'N'}"></td>--> <!-- <td th:text="${field.getDisabledFlag()==1?'Y':'N'}"></td>-->
<!-- <td th:text="${field.getAutocompleteFlag()==1?'Y':'N'}"></td>--> <!-- <td th:text="${field.getAutocompleteFlag()==1?'Y':'N'}"></td>-->
<!-- <td th:text="${field.getFieldMaxSize()}"></td>--> <!-- <td th:text="${field.getFieldMaxSize()}"></td>-->
<!-- <td th:text="${field.getFieldMinSize()}"></td>--> <!-- <td th:text="${field.getFieldMinSize()}"></td>-->
<!-- <td th:text="${field.getFieldMaxVal()}"></td>--> <!-- <td th:text="${field.getFieldMaxVal()}"></td>-->
<!-- <td th:text="${field.getFieldMinVal()}"></td>--> <!-- <td th:text="${field.getFieldMinVal()}"></td>-->
<!-- <td th:text="${field.getValidateRule()}"></td>--> <!-- <td th:text="${field.getValidateRule()}"></td>-->
<!-- <td th:text="${field.getValidateRuleMessage()}"></td>--> <!-- <td th:text="${field.getValidateRuleMessage()}"></td>-->
<!-- <td th:text="${field.getFormatFunc()}"></td>--> <!-- <td th:text="${field.getFormatFunc()}"></td>-->
<td> <td>
<a href="javascript:void(0)" <a href="javascript:void(0)"
@ -241,6 +242,16 @@
//装载数据模型字段 //装载数据模型字段
function fillModeDataField(data) { function fillModeDataField(data) {
if (data) { if (data) {
hiddenDiv();
if (data.fieldType === 'SELECT') {
document.getElementById("selectField-div").style.display = "block";
}
if(data.fieldType === 'NUMBER') {
showNumLimitDiv();
}
if(data.fieldType === 'TEXT') {
showTextLimitDiv();
}
fillForm("dataModelFieldForm", data); fillForm("dataModelFieldForm", data);
} }
} }
@ -333,4 +344,35 @@
JSON.stringify({id: parseInt(selectVal)})) JSON.stringify({id: parseInt(selectVal)}))
document.getElementById("_model_list").click(); document.getElementById("_model_list").click();
} }
function showDiv(obj) {
hiddenDiv();
if (obj.value === 'SELECT') {
document.getElementById("selectField-div").style.display = "block";
}
if(obj.value==="TEXT") {
showTextLimitDiv();
}
if(obj.value==="NUMBER") {
showNumLimitDiv();
}
}
function hiddenDiv() {
document.getElementById("textField-min-div").style.display = "none";
document.getElementById("textField-max-div").style.display = "none";
document.getElementById("numberField-min-div").style.display = "none";
document.getElementById("numberField-max-div").style.display = "none";
document.getElementById("selectField-div").style.display = "none";
}
function showNumLimitDiv(){
document.getElementById("numberField-min-div").style.display = "block";
document.getElementById("numberField-max-div").style.display = "block";
}
function showTextLimitDiv(){
document.getElementById("textField-min-div").style.display = "block";
document.getElementById("textField-max-div").style.display = "block";
}
</script> </script>

View File

@ -440,14 +440,14 @@
.style('font-size', '12px') .style('font-size', '12px')
.style('font-weight', '600') .style('font-weight', '600')
.style('fill', 'white') .style('fill', 'white')
.text(d => d.data.value >= 5 ? `${d.data.value.toFixed(0)}%` : ''); .text(d => d.data.value >= 5 ? `${d.data.value.toFixed(2)}%` : '');
// 图例:这里用 rows原始数据不是 d.data // 图例:这里用 rows原始数据不是 d.data
const legend = wrapper.append('div').attr('class', 'pie-legend'); const legend = wrapper.append('div').attr('class', 'pie-legend');
rows.forEach(d => { rows.forEach(d => {
const item = legend.append('div').attr('class', 'legend-item'); const item = legend.append('div').attr('class', 'legend-item');
item.append('div').attr('class', 'legend-color').style('background-color', d.color || '#999'); item.append('div').attr('class', 'legend-color').style('background-color', d.color || '#999');
item.append('span').text(`${d.label} (${d.value.toFixed(1)}%)`); item.append('span').text(`${d.label} (${d.value.toFixed(2)}%)`);
}); });
} }
@ -473,7 +473,7 @@
</td> </td>
<td> <td>
<div class="weight-display"> <div class="weight-display">
<div class="weight-value">${(item.weight * 100).toFixed(0)}%</div> <div class="weight-value">${(item.weight * 100).toFixed(2)}%</div>
<div class="weight-bar"> <div class="weight-bar">
<div class="weight-fill" style="width: ${item.weight * 100}%"></div> <div class="weight-fill" style="width: ${item.weight * 100}%"></div>
</div> </div>
@ -481,7 +481,7 @@
</td> </td>
<td>${createMembershipDistributionVisualization(item.membershipDist)}</td> <td>${createMembershipDistributionVisualization(item.membershipDist)}</td>
<td style="text-align: center; font-weight: 700; font-size: 1.1rem;">${item.score.toFixed( <td style="text-align: center; font-weight: 700; font-size: 1.1rem;">${item.score.toFixed(
1)}</td> 2)}</td>
<td><span class="score-badge ${scoreInfo.class}">${scoreInfo.level}</span></td> <td><span class="score-badge ${scoreInfo.class}">${scoreInfo.level}</span></td>
`; `;
@ -748,7 +748,7 @@
row.append('text') row.append('text')
.attr('x', d => x(d.score) + 8).attr('y', barH / 2).attr('dy', '.35em') .attr('x', d => x(d.score) + 8).attr('y', barH / 2).attr('dy', '.35em')
.attr('fill', '#0f172a').attr('font-weight', 800).attr('font-size', 18) .attr('fill', '#0f172a').attr('font-weight', 800).attr('font-size', 18)
.text(d => d.score.toFixed(1)); .text(d => d.score.toFixed(2));
// 最低分标注 // 最低分标注
const minScore = d3.min(src, d => d.score); const minScore = d3.min(src, d => d.score);

View File

@ -18,7 +18,7 @@
<div class="card-body"> <div class="card-body">
<div class="card section mb-3"> <div class="card section mb-3">
<div class="card-header"> <div class="card-header">
<div class="card-title">1.全局默认表(等级名/代表分)</div> <div class="card-title">1.全局默认表(百分制/等级名/代表分)</div>
</div> </div>
<div class="card-body"> <div class="card-body">
@ -29,8 +29,8 @@
<tr> <tr>
<th>等级名</th> <th>等级名</th>
<th>代表分</th> <th>等级代表分</th>
<th>代表值</th> <th>等级最低分</th>
</tr> </tr>
</thead> </thead>
@ -49,83 +49,13 @@
</td> </td>
<td> <td>
<label> <label>
<input type="text" th:value="${level.getEqualValue()}" style="width:8ch" name="_equalValue"/> <input type="text" th:value="${level.getLowValue()}" style="width:8ch" name="_lowValue"/>
</label> </label>
</td> </td>
</tr> </tr>
</th:block> </th:block>
<th:block th:if="${indicatorSetBean.getLevels()==null or indicatorSetBean.getLevels().size()==0 }">
<tr>
<td>
<label>
<input type="text" value="优" style="width:8ch" name="_level"/>
</label>
</td>
<td>
<label>
<input type="number" value="90" style="width:8ch" name="_score"/>
</label>
</td>
<td>
<label>
<input type="text" value="优" style="width:8ch" name="_equalValue"/>
</label>
</td>
</tr>
<tr>
<td>
<label>
<input type="text" value="良" style="width:8ch" name="_level"/>
</label>
</td>
<td>
<label>
<input type="number" value="80" style="width:8ch" name="_score"/>
</label>
</td>
<td>
<label>
<input type="text" value="良" style="width:8ch" name="_equalValue"/>
</label>
</td>
</tr>
<tr>
<td>
<label>
<input type="text" value="可" style="width:8ch" name="_level"/>
</label>
</td>
<td>
<label>
<input type="number" value="70" style="width:8ch" name="_score"/>
</label>
</td>
<td>
<label>
<input type="text" value="可" style="width:8ch" name="_equalValue"/>
</label>
</td>
</tr>
<tr>
<td>
<label>
<input type="text" value="差" style="width:8ch" name="_level"/>
</label>
</td>
<td>
<label>
<input type="number" value="60" style="width:8ch" name="_score"/>
</label>
</td>
<td>
<label>
<input type="text" value="差" style="width:8ch" name="_equalValue"/>
</label>
</td>
</tr>
</th:block>
</tbody> </tbody>
</table> </table>
</form> </form>
@ -229,12 +159,12 @@ function saveIndicatorGlobalSet(){
let levelGradeList = []; let levelGradeList = [];
let levelNames = document.getElementsByName("_level"); let levelNames = document.getElementsByName("_level");
let grades = document.getElementsByName("_score"); let grades = document.getElementsByName("_score");
let equalValues = document.getElementsByName("_equalValue"); let lowValues = document.getElementsByName("_lowValue");
for (let i = 0; i < levelNames.length; i++) { for (let i = 0; i < levelNames.length; i++) {
let level = {}; let level = {};
level.levelName = levelNames[i].value; level.levelName = levelNames[i].value;
level.grade = parseInt(grades[i].value); level.grade = parseInt(grades[i].value);
level.equalValue = (equalValues[i].value); level.lowValue = (lowValues[i].value);
levelGradeList.push(level); levelGradeList.push(level);
} }
//评价集设置 //评价集设置

View File

@ -20,4 +20,5 @@ public class Global {
* 日志记录队列. * 日志记录队列.
*/ */
public static LinkedBlockingQueue<Logs> logQueue = new LinkedBlockingQueue<>(1000); public static LinkedBlockingQueue<Logs> logQueue = new LinkedBlockingQueue<>(1000);
public static final int scale = 2;
} }

View File

@ -15,12 +15,12 @@ public class EvaluationLevel {
//分值 //分值
private double score; private double score;
//相等值 //相等值
private String equalValue; private String lowValue;
public EvaluationLevel(String levelName, double score, String equalValue) { public EvaluationLevel(String levelName, double score, String lowValue) {
this.levelName = levelName; this.levelName = levelName;
this.score = score; this.score = score;
this.equalValue = equalValue; this.lowValue = lowValue;
} }
public String getLevelName() { return levelName; } public String getLevelName() { return levelName; }

View File

@ -3,6 +3,7 @@ package com.hshh.system.base.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.hshh.system.base.entity.DictItem; import com.hshh.system.base.entity.DictItem;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 字典条目服务类. * 字典条目服务类.
@ -44,4 +45,5 @@ public interface DictItemService extends IService<DictItem> {
* @return 码表条目列表 * @return 码表条目列表
*/ */
List<DictItem> selectItemByTypeCode(String code); List<DictItem> selectItemByTypeCode(String code);
Map<Integer,List<DictItem>> dictItemMap();
} }

View File

@ -3,6 +3,7 @@ package com.hshh.system.base.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.hshh.system.base.entity.DictType; import com.hshh.system.base.entity.DictType;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* <p> * <p>
@ -29,4 +30,5 @@ public interface DictTypeService extends IService<DictType> {
* @return 当前最大排序号 * @return 当前最大排序号
*/ */
int maxOrder(); int maxOrder();
Map<Integer,DictType> dictTypeMap();
} }

View File

@ -5,7 +5,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hshh.system.base.entity.DictItem; import com.hshh.system.base.entity.DictItem;
import com.hshh.system.base.mapper.DictItemMapper; import com.hshh.system.base.mapper.DictItemMapper;
import com.hshh.system.base.service.DictItemService; import com.hshh.system.base.service.DictItemService;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -64,4 +69,16 @@ public class DictItemServiceImpl extends ServiceImpl<DictItemMapper, DictItem> i
public List<DictItem> selectItemByTypeCode(String code) { public List<DictItem> selectItemByTypeCode(String code) {
return this.baseMapper.selectItemByTypeCode(code); return this.baseMapper.selectItemByTypeCode(code);
} }
@Override
public Map<Integer, List<DictItem>> dictItemMap() {
List<DictItem> itemList = this.list();
itemList.sort(Comparator.comparing(DictItem::getId));
return itemList.stream()
.collect(Collectors.groupingBy(
DictItem::getTypeId,
LinkedHashMap::new, // 指定使用 LinkedHashMap
Collectors.toList()
));
}
} }

View File

@ -5,7 +5,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hshh.system.base.entity.DictType; import com.hshh.system.base.entity.DictType;
import com.hshh.system.base.mapper.DictTypeMapper; import com.hshh.system.base.mapper.DictTypeMapper;
import com.hshh.system.base.service.DictTypeService; import com.hshh.system.base.service.DictTypeService;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -45,4 +48,10 @@ public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> i
} }
return 0; return 0;
} }
@Override
public Map<Integer, DictType> dictTypeMap() {
return this.list().stream().collect(Collectors.toMap(DictType::getId, a -> a));
}
} }