diff --git a/.idea/misc.xml b/.idea/misc.xml index 4246b5e..2a08422 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -12,7 +12,7 @@ - + \ No newline at end of file diff --git a/attachment/Clipboard_2025-09-07-20-38-36.png b/attachment/Clipboard_2025-09-07-20-38-36.png new file mode 100644 index 0000000..af4628f Binary files /dev/null and b/attachment/Clipboard_2025-09-07-20-38-36.png differ diff --git a/attachment/Clipboard_2025-09-15-21-58-50.png b/attachment/Clipboard_2025-09-15-21-58-50.png new file mode 100644 index 0000000..6da93ed Binary files /dev/null and b/attachment/Clipboard_2025-09-15-21-58-50.png differ diff --git a/attachment/Clipboard_2025-09-15-21-59-14.png b/attachment/Clipboard_2025-09-15-21-59-14.png new file mode 100644 index 0000000..d03a460 Binary files /dev/null and b/attachment/Clipboard_2025-09-15-21-59-14.png differ diff --git a/attachment/Clipboard_2025-09-15-21-59-44.png b/attachment/Clipboard_2025-09-15-21-59-44.png new file mode 100644 index 0000000..5e8dbe1 Binary files /dev/null and b/attachment/Clipboard_2025-09-15-21-59-44.png differ diff --git a/attachment/Clipboard_2025-09-15-22-00-21.png b/attachment/Clipboard_2025-09-15-22-00-21.png new file mode 100644 index 0000000..b565050 Binary files /dev/null and b/attachment/Clipboard_2025-09-15-22-00-21.png differ diff --git a/attachment/Clipboard_2025-09-15-22-04-15.png b/attachment/Clipboard_2025-09-15-22-04-15.png new file mode 100644 index 0000000..9e2db3e Binary files /dev/null and b/attachment/Clipboard_2025-09-15-22-04-15.png differ diff --git a/attachment/Clipboard_2025-09-15-22-05-54.png b/attachment/Clipboard_2025-09-15-22-05-54.png new file mode 100644 index 0000000..60d79da Binary files /dev/null and b/attachment/Clipboard_2025-09-15-22-05-54.png differ diff --git a/attachment/Clipboard_2025-09-15-22-06-13.png b/attachment/Clipboard_2025-09-15-22-06-13.png new file mode 100644 index 0000000..11451b7 Binary files /dev/null and b/attachment/Clipboard_2025-09-15-22-06-13.png differ diff --git a/attachment/Clipboard_2025-09-15-22-06-29.png b/attachment/Clipboard_2025-09-15-22-06-29.png new file mode 100644 index 0000000..2933ce4 Binary files /dev/null and b/attachment/Clipboard_2025-09-15-22-06-29.png differ diff --git a/manager-admin/pom.xml b/manager-admin/pom.xml index 8605d3a..c028119 100644 --- a/manager-admin/pom.xml +++ b/manager-admin/pom.xml @@ -8,7 +8,7 @@ 1.0 - manager-admin + evaluation-indicator jar manager-admin @@ -39,15 +39,7 @@ - - org.apache.maven.plugins - maven-compiler-plugin - 3.11.0 - - 11 - 11 - - + org.springframework.boot spring-boot-maven-plugin diff --git a/manager-admin/src/main/demo.html b/manager-admin/src/main/demo.html deleted file mode 100644 index 41b895c..0000000 --- a/manager-admin/src/main/demo.html +++ /dev/null @@ -1,140 +0,0 @@ - - -替换雷达为横向条形图 · 最小示例 - - -
-

一级维度得分对比

-
- -
-
- - - diff --git a/manager-admin/src/main/java/com/hshh/config/DefaultIndicatorSetConfig.java b/manager-admin/src/main/java/com/hshh/config/DefaultIndicatorSetConfig.java new file mode 100644 index 0000000..b2a17a1 --- /dev/null +++ b/manager-admin/src/main/java/com/hshh/config/DefaultIndicatorSetConfig.java @@ -0,0 +1,67 @@ +package com.hshh.config; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.hshh.indicator.entity.IndicatorTopLevel; +import com.hshh.indicator.entity.IndicatorTopSet; +import java.io.File; +import java.io.InputStream; +import java.util.List; +import java.util.Map; +import javax.annotation.PostConstruct; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * [类的简要说明] + *

+ * [详细描述,可选] + *

+ * + * @author LiDongYU + * @since 2025/7/22 + */ +@Component +@Slf4j +@Data +public class DefaultIndicatorSetConfig { + + private static final String configPath = "./config/indicator_set.yaml"; + private List levels; + private IndicatorTopSet function; + + @PostConstruct + void load() { + try { + + ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); + Map root; + //首先查找配置 + if (new File(configPath).exists()) { + root = mapper.readValue(new File(configPath), Map.class); + + } else { //读取classpath + try (InputStream input = DefaultIndicatorSetConfig.class.getClassLoader() + .getResourceAsStream("indicator_set.yaml")) { + + root = mapper.readValue(input, Map.class); + + } + } + Map indicator = (Map) root.get("indicator"); + Map def = (Map) indicator.get("default"); + this.levels = mapper.convertValue(def.get("levels"), + new TypeReference>() { + }); + this.function = mapper.convertValue(def.get("function"), IndicatorTopSet.class); + log.info(" this.function::{}", this.function); + } catch (Exception e) { + log.error("error:", e); + } + + + } + +} diff --git a/manager-admin/src/main/java/com/hshh/config/IndicatorConfig.java b/manager-admin/src/main/java/com/hshh/config/IndicatorConfig.java new file mode 100644 index 0000000..5aa84c1 --- /dev/null +++ b/manager-admin/src/main/java/com/hshh/config/IndicatorConfig.java @@ -0,0 +1,29 @@ +package com.hshh.config; + + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.hshh.indicator.entity.IndicatorTopLevel; +import com.hshh.indicator.entity.IndicatorTopSet; +import java.util.List; +import java.util.Map; +import lombok.Data; + +/** + * [类的简要说明] + *

+ * [详细描述,可选] + *

+ * + * @author LiDongYU + * @since 2025/7/22 + */ +@Data +public class IndicatorConfig { + + @JsonCreator + public IndicatorConfig(Map root) { + + } +} diff --git a/manager-admin/src/main/java/com/hshh/data/controller/DataController.java b/manager-admin/src/main/java/com/hshh/data/controller/DataController.java index ea681ae..d5fb784 100644 --- a/manager-admin/src/main/java/com/hshh/data/controller/DataController.java +++ b/manager-admin/src/main/java/com/hshh/data/controller/DataController.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; @@ -74,7 +75,7 @@ public class DataController extends BaseController { @LogOperation("进入数据管理") @GetMapping("/list") @Operation(summary = "导航到数据管理页面", description = "导航到数据管理页面") - public String index(PaginationBean request, Model model) { + public String index(PaginationBean request, Model model, HttpServletRequest httpServletRequest) { setNavigateTitle(model, "/data/list"); List modelDefineList = modelDefineService.list(); //查询所有数据模型列表 modelDefineList.sort(Comparator.comparing(ModelDefine::getSortOrder)); //对模型数据列表排序 @@ -154,7 +155,8 @@ public class DataController extends BaseController { @GetMapping("/getForm/{id}") @Operation(summary = "获取form输入窗体", description = "根据模型ID获取form窗体") @ResponseBody - public OperateResult getForm(@PathVariable("id") Integer id) { + public OperateResult getForm(@PathVariable("id") Integer id, + HttpServletRequest httpServletRequest) { return OperateResult.success(dataRecordService.html(id), ErrorMessage.SUCCESS.getMessage()); } @@ -169,7 +171,8 @@ public class DataController extends BaseController { @PostMapping("/form/save") @ResponseBody @Operation(summary = "保存记录", description = "保存对应模型ID对应的form表单记录") - public OperateResult saveRecord(@RequestBody FormValue formValue) { + public OperateResult saveRecord(@RequestBody FormValue formValue, + HttpServletRequest httpServletRequest) { //验证字段合法性 Integer modelId = formValue.getModelDefineId(); @@ -193,7 +196,8 @@ public class DataController extends BaseController { @ResponseBody @GetMapping("/remove/{id}") @Operation(summary = "删除记录", description = "根据ID删除记录") - public OperateResult remove(@PathVariable("id") Integer id) { + public OperateResult remove(@PathVariable("id") Integer id + ) { formValueService.removeById(id); return OperateResult.success(); } @@ -207,7 +211,8 @@ public class DataController extends BaseController { @ResponseBody @GetMapping("/{id}") @Operation(summary = "删除记录", description = "根据ID删除记录") - public OperateResult view(@PathVariable("id") Integer id) { + public OperateResult view(@PathVariable("id") Integer id + ) { FormValue formValue = formValueService.getById(id); if (formValue == null) { return OperateResult.error(null, ErrorMessage.ID_NOT_EXIT.getMessage(), diff --git a/manager-admin/src/main/java/com/hshh/data/service/DataRecordService.java b/manager-admin/src/main/java/com/hshh/data/service/DataRecordService.java index 9e13f91..4ff21f7 100644 --- a/manager-admin/src/main/java/com/hshh/data/service/DataRecordService.java +++ b/manager-admin/src/main/java/com/hshh/data/service/DataRecordService.java @@ -28,4 +28,5 @@ public interface DataRecordService { * @return 错误信息 */ List getErrorField(List formConfigList, FormValue formValue); + void deleteFromByModelId(Integer id); } diff --git a/manager-admin/src/main/java/com/hshh/data/service/impl/DataRecordServiceImpl.java b/manager-admin/src/main/java/com/hshh/data/service/impl/DataRecordServiceImpl.java index 559ab3b..eacb3ea 100644 --- a/manager-admin/src/main/java/com/hshh/data/service/impl/DataRecordServiceImpl.java +++ b/manager-admin/src/main/java/com/hshh/data/service/impl/DataRecordServiceImpl.java @@ -116,6 +116,22 @@ public class DataRecordServiceImpl implements DataRecordService { .append(field.getFieldId()) .append("\" class=\"form-control\" autocomplete=\"off\" >"); break; + case DATE: + sb.append(""); + break; + case DATETIME: + sb.append(""); + break; + case TIME: + sb.append(""); + break; default: break; } @@ -134,4 +150,9 @@ public class DataRecordServiceImpl implements DataRecordService { return errorFieldList; } + + @Override + public void deleteFromByModelId(Integer id) { + + } } diff --git a/manager-admin/src/main/java/com/hshh/evaluation/controller/EvaluationProjectController.java b/manager-admin/src/main/java/com/hshh/evaluation/controller/EvaluationProjectController.java index fe54d54..992457a 100644 --- a/manager-admin/src/main/java/com/hshh/evaluation/controller/EvaluationProjectController.java +++ b/manager-admin/src/main/java/com/hshh/evaluation/controller/EvaluationProjectController.java @@ -40,6 +40,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -73,11 +74,7 @@ public class EvaluationProjectController extends AssistantEvaluationProjectContr @Resource private EvaluationTemplateService evaluationTemplateService; - /** - * 数据库引用关系记录服务类. - */ - @Resource - private TableRelationsService tableRelationsService; + /** * 基础设施服务类. @@ -141,7 +138,13 @@ public class EvaluationProjectController extends AssistantEvaluationProjectContr * @return evaluation/add.html */ @GetMapping("/add") - public String add(Model model) { + public String add(Model model, HttpServletRequest request) { + int id = + request.getParameter("id") == null ? 0 : Integer.parseInt(request.getParameter("id")); + if (id != 0) { + EvaluationProject project = evaluationProjectService.getById(id); + model.addAttribute("project", project); + } List rootList = evaluationTemplateService.list(); model.addAttribute("rootList", rootList); return "project/add"; @@ -191,12 +194,8 @@ public class EvaluationProjectController extends AssistantEvaluationProjectContr @GetMapping("/remove/{id}") @LogOperation("删除工程") public OperateResult remove(@PathVariable("id") Integer id) { - List reList = tableRelationsService.queryRel(id, "m_data_evaluation_project"); - if (!reList.isEmpty()) { - return OperateResult.error(null, ErrorMessage.OBJ_ALREADY_TAKEN.getMessage(), - ErrorCode.BUSINESS_ERROR.getCode()); - } - evaluationProjectService.removeById(id); + + evaluationProjectService.deleteTheWholeProject(id); return OperateResult.success(); } @@ -274,9 +273,7 @@ public class EvaluationProjectController extends AssistantEvaluationProjectContr if (params.get("templateId") != null) { model.addAttribute("templateId", params.get("templateId")); } - if (params.get("method") != null) { - model.addAttribute("method", params.get("method")); - } + if (params.get("search") != null) { model.addAttribute("search", params.get("search")); } @@ -356,7 +353,7 @@ public class EvaluationProjectController extends AssistantEvaluationProjectContr ra.addAttribute("id", uploadInfo.getProjectId()); ra.addAttribute("search", uploadInfo.getSearch()); ra.addAttribute("randomKey", uploadInfo.getRandomKey()); - ra.addAttribute("method", uploadInfo.getMethod()); + for (Map.Entry entry : params.entrySet()) { ra.addAttribute(entry.getKey(), entry.getValue()); } @@ -442,7 +439,7 @@ public class EvaluationProjectController extends AssistantEvaluationProjectContr reportBean.setBottomNum(bottomNum); //设置所在评价集区间名称 - List levelList = topLevelService.getTopLevel(rootResult.getIndicatorTopId()); + List levelList = topLevelService.getTopLevel(); levelList.sort((a, b) -> Double.compare(Double.parseDouble(b.getGrade()), Double.parseDouble(a.getGrade()))); setLevelName(levelList, rootResult); @@ -502,5 +499,11 @@ public class EvaluationProjectController extends AssistantEvaluationProjectContr return "project/evaluation_history"; } + @GetMapping("/history/remove/{randomKey}") + @ResponseBody + public OperateResult deleteFromRandomKey(@PathVariable("randomKey") String randomKey) { + evaluationHistoryService.removeByRandomKey(randomKey); + return OperateResult.success(); + } } diff --git a/manager-admin/src/main/java/com/hshh/evaluation/controller/EvaluationTemplateController.java b/manager-admin/src/main/java/com/hshh/evaluation/controller/EvaluationTemplateController.java index b665531..b838fe6 100644 --- a/manager-admin/src/main/java/com/hshh/evaluation/controller/EvaluationTemplateController.java +++ b/manager-admin/src/main/java/com/hshh/evaluation/controller/EvaluationTemplateController.java @@ -3,19 +3,21 @@ package com.hshh.evaluation.controller; import com.hshh.evaluation.bean.PageMetricComputeRequest; import com.hshh.evaluation.bean.PageMetricComputerResponse; import com.hshh.evaluation.bean.PageMetricMapperWeightBean; +import com.hshh.evaluation.entity.EvaluationProject; import com.hshh.evaluation.entity.EvaluationTemplate; import com.hshh.evaluation.entity.EvaluationTemplateWeight; +import com.hshh.evaluation.service.EvaluationProjectService; import com.hshh.evaluation.service.EvaluationTemplateIndicatorWeightService; import com.hshh.evaluation.service.EvaluationTemplateService; import com.hshh.evaluation.service.EvaluationTemplateWeightService; import com.hshh.indicator.entity.Indicator; import com.hshh.indicator.service.IndicatorService; +import com.hshh.system.algorithm.ahp.AhpNode; +import com.hshh.system.algorithm.ahp.AhpTreeCompute; import com.hshh.system.annotation.LogOperation; import com.hshh.system.base.entity.TableRelations; import com.hshh.system.base.service.TableRelationsService; import com.hshh.system.common.Strings.StringUtil; -import com.hshh.system.algorithm.ahp.AhpNode; -import com.hshh.system.algorithm.ahp.AhpTreeCompute; import com.hshh.system.common.bean.JsTree; import com.hshh.system.common.bean.OperateResult; import com.hshh.system.common.bean.PaginationBean; @@ -62,11 +64,7 @@ public class EvaluationTemplateController extends AssistantTemplateController { @Resource private IndicatorService indicatorService; - /** - * 数据库引用关系记录服务类. - */ - @Resource - private TableRelationsService tableRelationsService; + /** * 权重服务详情类. @@ -78,7 +76,8 @@ public class EvaluationTemplateController extends AssistantTemplateController { */ @Resource private EvaluationTemplateIndicatorWeightService evaluationTemplateIndicatorWeightService; - + @Resource + private EvaluationProjectService evaluationProjectService; /** * 默认页. @@ -154,10 +153,10 @@ public class EvaluationTemplateController extends AssistantTemplateController { @ResponseBody @LogOperation("删除模板") public OperateResult remove(@PathVariable("id") Integer id) { - List reledList = tableRelationsService.queryRel(id, - "m_data_evaluation_template"); - if (!reledList.isEmpty()) { - return OperateResult.error(null, ErrorMessage.OBJ_ALREADY_TAKEN.getMessage(), + List projectList = evaluationProjectService.getByTemplateId(id); + + if (!projectList.isEmpty()) { + return OperateResult.error(null, "有关联的工程占用", ErrorCode.BUSINESS_ERROR.getCode()); } evaluationTemplateService.deleteTemplate(evaluationTemplateService.getById(id)); diff --git a/manager-admin/src/main/java/com/hshh/evaluation/service/EvaluationCsvDataService.java b/manager-admin/src/main/java/com/hshh/evaluation/service/EvaluationCsvDataService.java index 2d91290..dab0d74 100644 --- a/manager-admin/src/main/java/com/hshh/evaluation/service/EvaluationCsvDataService.java +++ b/manager-admin/src/main/java/com/hshh/evaluation/service/EvaluationCsvDataService.java @@ -47,4 +47,6 @@ public interface EvaluationCsvDataService extends IService { * @return 结果列表 */ List selectByIds(@Param("ids") List ids); + void deleteFromRandomKey(String key); + void deleteByProjectId(Integer projectId); } diff --git a/manager-admin/src/main/java/com/hshh/evaluation/service/EvaluationHistoryService.java b/manager-admin/src/main/java/com/hshh/evaluation/service/EvaluationHistoryService.java index aff81f3..1fdbb62 100644 --- a/manager-admin/src/main/java/com/hshh/evaluation/service/EvaluationHistoryService.java +++ b/manager-admin/src/main/java/com/hshh/evaluation/service/EvaluationHistoryService.java @@ -35,4 +35,7 @@ public interface EvaluationHistoryService extends IService { * @return 历史记录 */ List queryListByProjectId(Integer projectId); + + void removeByRandomKey(String randomKey); + List queryRandomKeysByProjectId(Integer projectId); } diff --git a/manager-admin/src/main/java/com/hshh/evaluation/service/EvaluationProjectService.java b/manager-admin/src/main/java/com/hshh/evaluation/service/EvaluationProjectService.java index 7571ab3..084df4b 100644 --- a/manager-admin/src/main/java/com/hshh/evaluation/service/EvaluationProjectService.java +++ b/manager-admin/src/main/java/com/hshh/evaluation/service/EvaluationProjectService.java @@ -69,4 +69,6 @@ public interface EvaluationProjectService extends IService { * @param uploadInfo csv文件信息 */ void uploadCsv(CsvUploadBean uploadInfo) throws IOException; + List getByTemplateId(Integer templateId); + void deleteTheWholeProject(Integer id); } diff --git a/manager-admin/src/main/java/com/hshh/evaluation/service/impl/CoreEvaluationServiceImpl.java b/manager-admin/src/main/java/com/hshh/evaluation/service/impl/CoreEvaluationServiceImpl.java index 45f7f7a..43ac8c2 100644 --- a/manager-admin/src/main/java/com/hshh/evaluation/service/impl/CoreEvaluationServiceImpl.java +++ b/manager-admin/src/main/java/com/hshh/evaluation/service/impl/CoreEvaluationServiceImpl.java @@ -2,6 +2,7 @@ package com.hshh.evaluation.service.impl; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; +import com.hshh.config.DefaultIndicatorSetConfig; import com.hshh.evaluation.bean.PageEvaluationRequest; import com.hshh.evaluation.bean.SingleEvaluationData; import com.hshh.evaluation.entity.EvaluationCsvData; @@ -83,7 +84,8 @@ public class CoreEvaluationServiceImpl implements CoreEvaluationService { private EvaluationHistoryService evaluationHistoryService; //评估历史批次记录 @Resource private EvaluationRootResultService evaluationRootResultService; //评估详情及概况记录 - + @Resource + private DefaultIndicatorSetConfig defaultIndicatorSetConfig; // 定义分页大小常量,便于管理 private static final int DEFAULT_PAGE_SIZE = 100; @@ -101,8 +103,10 @@ public class CoreEvaluationServiceImpl implements CoreEvaluationService { Integer indicatorTopId = template.getIndicatorTopId(); request.setIndicatorTopId(indicatorTopId); IndicatorTopSet membershipFuncSet = getMembershipFuncSetOrThrow(indicatorTopId); //隶属函数设置 + List topLevelList = getTopLevelListOrThrow(indicatorTopId); //评价集区间 - Indicator indicator = indicatorService.getIndicator(indicatorTopId); //获取指标 + + Indicator indicator = indicatorService.getRecursionIndicator(indicatorTopId); //获取指标 Map indicatorWeightMap = evaluationTemplateIndicatorWeightService.getEvaluationTemplateIndicatorWeightMap( indicatorTopId, template.getId()); //指标权重map @@ -167,10 +171,12 @@ public class CoreEvaluationServiceImpl implements CoreEvaluationService { DataSourceStrategy strategy, Map indicatorWeightMap, Map> indicatorEvalItemMap) { - //首先记录本次评估 + //获取全局评估函数 request.setMembership(membershipFuncSet.getMembershipFunc()); + //设置运算方式 + request.setMethod(membershipFuncSet.getMethod()); evaluationHistoryService.saveWhole(request); - + //查看是否指定某些记录进行评估 boolean hasSpecificIds = request.getIds() != null && request.getIds().length > 0; if (hasSpecificIds) { @@ -324,17 +330,17 @@ public class CoreEvaluationServiceImpl implements CoreEvaluationService { } private IndicatorTopSet getMembershipFuncSetOrThrow(Integer indicatorTopId) { - IndicatorTopSet set = indicatorTopSetService.getIndicatorTopSet(indicatorTopId); + IndicatorTopSet set = indicatorTopSetService.getIndicatorTopSet(); if (set == null) { - throw new EvaluationException("没有找到对应的隶属度函数"); + return defaultIndicatorSetConfig.getFunction(); } return set; } private List getTopLevelListOrThrow(Integer indicatorTopId) { - List list = indicatorTopLevelService.getTopLevel(indicatorTopId); + List list = indicatorTopLevelService.getTopLevel(); if (list == null || list.isEmpty()) { - throw new EvaluationException("没有找到全局指标集区间和分值"); + return defaultIndicatorSetConfig.getLevels(); } return list; } @@ -354,14 +360,15 @@ public class CoreEvaluationServiceImpl implements CoreEvaluationService { topLevelList.forEach(topLevel -> { EvaluationLevel evaluationLevel = new EvaluationLevel(topLevel.getLevelName(), - Double.parseDouble(topLevel.getGrade())); + Double.parseDouble(topLevel.getGrade()), + topLevel.getEqualValue() == null ? "" : topLevel.getEqualValue()); evaluationLevels.add(evaluationLevel); }); return new GlobalEvaluationConfig(evaluationLevels); } /** - * 核心评估触发点(此方法保持不变). + * 核心评估触发点. */ private void startEvaluation(PageEvaluationRequest request, Integer userId, IndicatorTopSet membershipFuncSet, List topLevelList, @@ -409,7 +416,8 @@ public class CoreEvaluationServiceImpl implements CoreEvaluationService { globalEvaluationConfig, membershipFuncSet, indicatorEvalItemMap); FuzzyEvaluationService service = new FuzzyEvaluationService(globalEvaluationConfig); - service.performFuzzyEvaluation(root, FuzzyOperator.valueOf(request.getMethod())); + //核心评估行为 + service.performFuzzyEvaluation(root, FuzzyOperator.valueOf(membershipFuncSet.getMethod())); resultList.add(root); } saveResult(resultList); @@ -457,6 +465,7 @@ public class CoreEvaluationServiceImpl implements CoreEvaluationService { Double.parseDouble(membershipFuncSet.getTrianglePeakRatio()), Double.parseDouble(membershipFuncSet.getSoftEdgeS()), globalEvaluationConfig)); + //设置权重 childNode.setWeight(indicatorWeightMap.get(child.getId()) == null ? 1 : Double.parseDouble(indicatorWeightMap.get(child.getId()))); @@ -473,7 +482,7 @@ public class CoreEvaluationServiceImpl implements CoreEvaluationService { if (fieldName != null) { Object currentValue = valueMap.get(fieldName); if (currentValue != null) { - node.setActualValue(Double.parseDouble(currentValue.toString())); + node.setActualValue(currentValue); } } @@ -499,6 +508,7 @@ public class CoreEvaluationServiceImpl implements CoreEvaluationService { } } + //设置节点的评价集范围 private List getGradeRange(List indicatorEvalItemList) { List list = new ArrayList<>(); indicatorEvalItemList.sort( @@ -506,7 +516,7 @@ public class CoreEvaluationServiceImpl implements CoreEvaluationService { indicatorEvalItemList.forEach(indicatorEvalItem -> { GradeRange gradeRange = new GradeRange(indicatorEvalItem.getEvaluationName(), Double.parseDouble(indicatorEvalItem.getBottomValue()), - Double.parseDouble(indicatorEvalItem.getTopValue())); + Double.parseDouble(indicatorEvalItem.getTopValue()), indicatorEvalItem.getEqualValue()); list.add(gradeRange); }); return list; diff --git a/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationCsvDataServiceImpl.java b/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationCsvDataServiceImpl.java index c7142d1..c811372 100644 --- a/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationCsvDataServiceImpl.java +++ b/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationCsvDataServiceImpl.java @@ -1,6 +1,7 @@ package com.hshh.evaluation.service.impl; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hshh.evaluation.bean.CsvUploadBean; import com.hshh.evaluation.entity.EvaluationCsvData; @@ -58,4 +59,18 @@ public class EvaluationCsvDataServiceImpl extends public List selectByIds(List ids) { return this.baseMapper.selectByIds(ids); } + + @Override + public void deleteFromRandomKey(String key) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("random_key", key); + remove(queryWrapper); + } + + @Override + public void deleteByProjectId(Integer projectId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("project_id", projectId); + remove(queryWrapper); + } } diff --git a/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationHistoryServiceImpl.java b/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationHistoryServiceImpl.java index c57a15e..a5730a9 100644 --- a/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationHistoryServiceImpl.java +++ b/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationHistoryServiceImpl.java @@ -5,9 +5,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hshh.evaluation.bean.PageEvaluationRequest; import com.hshh.evaluation.entity.EvaluationHistory; import com.hshh.evaluation.mapper.EvaluationHistoryMapper; +import com.hshh.evaluation.service.EvaluationCsvDataService; import com.hshh.evaluation.service.EvaluationHistoryService; +import com.hshh.evaluation.service.EvaluationRootResultService; import java.time.LocalDateTime; +import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; +import javax.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -24,6 +29,11 @@ public class EvaluationHistoryServiceImpl extends ServiceImpl implements EvaluationHistoryService { + @Resource + private EvaluationRootResultService evaluationRootResultService; + @Resource + private EvaluationCsvDataService evaluationCsvDataService; + @Transactional @Override public void saveWhole(PageEvaluationRequest request) { @@ -54,4 +64,22 @@ public class EvaluationHistoryServiceImpl extends queryWrapper.orderByDesc("id"); return this.baseMapper.selectList(queryWrapper); } + + @Transactional(rollbackFor = Exception.class) + @Override + public void removeByRandomKey(String randomKey) { + evaluationRootResultService.deleteByRandomKey(randomKey); + evaluationCsvDataService.deleteFromRandomKey(randomKey); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("random_key", randomKey); + remove(queryWrapper); + } + + @Override + public List queryRandomKeysByProjectId(Integer projectId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("project_id", projectId); + + return this.list(queryWrapper).stream().map(EvaluationHistory::getRandomKey).collect(Collectors.toList()); + } } diff --git a/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationProjectServiceImpl.java b/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationProjectServiceImpl.java index 798db1f..ec97127 100644 --- a/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationProjectServiceImpl.java +++ b/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationProjectServiceImpl.java @@ -8,24 +8,18 @@ import com.hshh.evaluation.entity.EvaluationProject; import com.hshh.evaluation.mapper.EvaluationProjectMapper; import com.hshh.evaluation.service.CoreEvaluationService; import com.hshh.evaluation.service.EvaluationCsvDataService; +import com.hshh.evaluation.service.EvaluationHistoryService; import com.hshh.evaluation.service.EvaluationProjectService; import com.hshh.system.base.service.TableRelationsService; import com.hshh.system.common.bean.PaginationBean; +import com.hshh.system.common.util.FileUtil; import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import javax.annotation.Resource; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.csv.CSVFormat; -import org.apache.commons.csv.CSVParser; -import org.apache.commons.csv.CSVRecord; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -58,8 +52,8 @@ public class EvaluationProjectServiceImpl extends */ @Resource private CoreEvaluationService coreEvaluationService; - - + @Resource + private EvaluationHistoryService evaluationHistoryService; @Override public List list(PaginationBean paginationBean) { return this.baseMapper.list(paginationBean); @@ -110,39 +104,46 @@ public class EvaluationProjectServiceImpl extends @Override public void uploadCsv(CsvUploadBean uploadInfo) throws IOException { - CSVFormat format = CSVFormat.DEFAULT - .builder() - .setHeader() // 表示第一行就是表头 - .setSkipHeaderRecord(true) // 跳过第一行数据,不把它算到记录里 - .setIgnoreEmptyLines(true) - .setTrim(true) - .build(); - //获取表头信息 + List> rows = new ArrayList<>(); - try (Reader reader = new InputStreamReader(uploadInfo.getFile().getInputStream(), - StandardCharsets.UTF_8); - CSVParser parser = new CSVParser(reader, format)) { - - // 取有序表头:Apache 返回 Map<列名, 索引>,按索引排序得到原始顺序 - List headers = parser.getHeaderMap() - .entrySet() - .stream() - .sorted(Comparator.comparingInt(Map.Entry::getValue)) - .map(Map.Entry::getKey) - .collect(Collectors.toList()); - - for (CSVRecord rec : parser) { - Map obj = new LinkedHashMap<>(); - for (String h : headers) { - // get(h):按列名取值,可能为 null - obj.put(h, rec.isMapped(h) ? rec.get(h) : null); - } - rows.add(obj); - - - } - evaluationCsvDataService.saveWhole(rows, uploadInfo); + List> dataList = FileUtil.parseCsvFromInputStream(uploadInfo.getFile()); + if (dataList.isEmpty()) { + return; } + List headers = dataList.get(0); + for (int i = 1; i < dataList.size(); i++) { + Map row = new LinkedHashMap<>(); + List data = dataList.get(i); + for (int j = 0; j < data.size(); j++) { + row.put(headers.get(j), data.get(j)); + } + rows.add(row); + } + evaluationCsvDataService.saveWhole(rows, uploadInfo); + } + + @Override + public List getByTemplateId(Integer templateId) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("template_id", templateId); + + return this.list(wrapper); + } + + @Override + @Transactional + public void deleteTheWholeProject(Integer id) { + //删除关联表csv_data + evaluationCsvDataService.deleteByProjectId(id); + + //删除历史表 + List historyRandomList = evaluationHistoryService.queryRandomKeysByProjectId(id); + historyRandomList.forEach(historyRandom -> { + evaluationHistoryService.removeByRandomKey(historyRandom); + }); + + this.removeById(id); + } } diff --git a/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationTemplateIndicatorWeightServiceImpl.java b/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationTemplateIndicatorWeightServiceImpl.java index 580d926..b3ca42c 100644 --- a/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationTemplateIndicatorWeightServiceImpl.java +++ b/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationTemplateIndicatorWeightServiceImpl.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hshh.evaluation.entity.EvaluationTemplateIndicatorWeight; import com.hshh.evaluation.mapper.EvaluationTemplateIndicatorWeightMapper; import com.hshh.evaluation.service.EvaluationTemplateIndicatorWeightService; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -36,7 +37,7 @@ public class EvaluationTemplateIndicatorWeightServiceImpl extends Collectors.toMap(EvaluationTemplateIndicatorWeight::getIndicatorId, EvaluationTemplateIndicatorWeight::getWeight)); } - return Map.of(); + return new HashMap<>(); } @Transactional(rollbackFor = Exception.class) diff --git a/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationTemplateWeightServiceImpl.java b/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationTemplateWeightServiceImpl.java index 1f2efce..86a58c9 100644 --- a/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationTemplateWeightServiceImpl.java +++ b/manager-admin/src/main/java/com/hshh/evaluation/service/impl/EvaluationTemplateWeightServiceImpl.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hshh.evaluation.entity.EvaluationTemplateWeight; import com.hshh.evaluation.mapper.EvaluationTemplateWeightMapper; import com.hshh.evaluation.service.EvaluationTemplateWeightService; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -43,7 +44,7 @@ public class EvaluationTemplateWeightServiceImpl extends return list.stream() .collect(Collectors.groupingBy(EvaluationTemplateWeight::getIndicatorParentId)); } - return Map.of(); + return new HashMap<>(); } @Override diff --git a/manager-admin/src/main/java/com/hshh/indicator/controller/EvaluationController.java b/manager-admin/src/main/java/com/hshh/indicator/controller/EvaluationController.java index 83bb7d1..29aeca5 100644 --- a/manager-admin/src/main/java/com/hshh/indicator/controller/EvaluationController.java +++ b/manager-admin/src/main/java/com/hshh/indicator/controller/EvaluationController.java @@ -3,10 +3,10 @@ package com.hshh.indicator.controller; import com.hshh.indicator.bean.IndicatorEvalBean; import com.hshh.indicator.entity.Indicator; import com.hshh.indicator.entity.IndicatorEvalItem; +import com.hshh.indicator.entity.IndicatorTopLevel; import com.hshh.indicator.service.IndicatorEvalItemService; import com.hshh.indicator.service.IndicatorService; import com.hshh.indicator.service.IndicatorTopLevelService; -import com.hshh.indicator.service.IndicatorTopSetService; import com.hshh.system.annotation.LogOperation; import com.hshh.system.common.bean.BaseController; import com.hshh.system.common.bean.JsTree; @@ -46,6 +46,8 @@ public class EvaluationController extends BaseController { */ @Resource private IndicatorEvalItemService indicatorEvalItemService; + @Resource + private IndicatorTopLevelService indicatorTopLevelService; /** * 导航到评价集设置页面. @@ -56,6 +58,9 @@ public class EvaluationController extends BaseController { public String evaluationList(Model model) { setNavigateTitle(model, "/evaluation/evaluationList"); List bottomList = indicatorService.queryRootList(); + //查询全局评价级别 + List levelList = indicatorTopLevelService.getTopLevel(); + model.addAttribute("levelList", levelList); model.addAttribute("rootList", bottomList); return "indicator/evaluation_list"; } @@ -104,7 +109,7 @@ public class EvaluationController extends BaseController { child.setText(a.getName()); if (evalMap.containsKey(a.getId())) { List evalItemList = evalMap.get(a.getId()); - evalItemList = evalItemList.stream().peek(aa -> { + evalItemList = evalItemList.stream().peek(aa -> { if (aa.getEqualValue() == null) { aa.setEqualValue(""); } diff --git a/manager-admin/src/main/java/com/hshh/indicator/controller/IndicatorController.java b/manager-admin/src/main/java/com/hshh/indicator/controller/IndicatorController.java index bef7995..1b2afea 100644 --- a/manager-admin/src/main/java/com/hshh/indicator/controller/IndicatorController.java +++ b/manager-admin/src/main/java/com/hshh/indicator/controller/IndicatorController.java @@ -23,13 +23,17 @@ import com.hshh.system.common.bean.CheckedBean; import com.hshh.system.common.bean.OperateResult; import com.hshh.system.common.enums.ErrorCode; import com.hshh.system.common.enums.ErrorMessage; +import com.hshh.system.common.util.StringTool; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStreamReader; import java.io.OutputStream; import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; @@ -151,7 +155,7 @@ public class IndicatorController extends BaseController { @ResponseBody @GetMapping("/{id}") public OperateResult view(@PathVariable("id") Integer id) { - Indicator indicator = indicatorService.getIndicator(id); + Indicator indicator = indicatorService.getRecursionIndicator(id); if (indicator == null) { return OperateResult.error(null, ErrorMessage.ID_NOT_EXIT.getMessage(), ErrorCode.BUSINESS_ERROR.getCode()); @@ -175,23 +179,28 @@ public class IndicatorController extends BaseController { if (bindingResult.hasErrors()) { return errorsInputHandle(bindingResult); } - //查看名称或者编码是否重复 - List exitList = indicatorService.queryList(indicator.getTopId(), indicator.getName(), - indicator.getCode()); + if (indicator.getParentId() == null) { + indicator.setParentId(0); + } + //查看名称 + List exitList = indicatorService.queryList(indicator.getParentId(), + indicator.getName() + ); if (indicator.getId() == null) { if (!exitList.isEmpty()) { - return OperateResult.error(null, ErrorMessage.NAME_OR_CODE_EXIT.getMessage(), + return OperateResult.error(null, ErrorMessage.NAME_EXIT.getMessage(), ErrorCode.BUSINESS_ERROR.getCode()); } indicatorService.save(indicator); } else { //编辑 if (!exitList.isEmpty()) { if (!exitList.get(0).getId().equals(indicator.getId())) { - return OperateResult.error(null, ErrorMessage.NAME_OR_CODE_EXIT.getMessage(), + return OperateResult.error(null, ErrorMessage.NAME_EXIT.getMessage(), ErrorCode.BUSINESS_ERROR.getCode()); } - indicatorService.updateById(indicator); + } + indicatorService.updateById(indicator); } return OperateResult.success(indicator, ErrorMessage.SUCCESS.getMessage()); } @@ -206,18 +215,13 @@ public class IndicatorController extends BaseController { @ResponseBody @LogOperation("删除指标") @Operation(summary = "删除指标", description = "根据ID删除指定指标") - public OperateResult remove(@PathVariable("id") Integer id) { + public OperateResult remove(@PathVariable("id") Integer id) throws Exception { if (id == null) { return OperateResult.error(null, ErrorMessage.ID_NOT_EXIT.getMessage(), ErrorCode.BUSINESS_ERROR.getCode()); } - //查询此ID下是否有子指标 - List children = indicatorService.queryChildren(id); - if (children != null && !children.isEmpty()) { - return OperateResult.error(null, ErrorMessage.OBJ_HAS_SUB.getMessage(), - ErrorCode.BUSINESS_ERROR.getCode()); - } - indicatorService.removeById(id); + + indicatorService.deleteIndicator(id); return OperateResult.success(); } @@ -245,8 +249,8 @@ public class IndicatorController extends BaseController { model.addAttribute("rootList", rootList); // 底层指标放入session容器 if (indicatorTopId != null) { - model.addAttribute("childrenIndicator", indicatorService.selectNoChildByTopId( - indicatorTopId)); + model.addAttribute("childrenIndicator", + indicatorService.selectNoChildByTopId(indicatorTopId)); } // form表单和顶级指标对应列表放入session容器 @@ -262,8 +266,7 @@ public class IndicatorController extends BaseController { indicatorTopId == null ? (rootList.isEmpty() ? 0 : rootList.get(0).getId()) : indicatorTopId); Map bottomFormMap = bottomList.stream() - .filter(a -> a.getFormFieldId() != null) - .collect( + .filter(a -> a.getFormFieldId() != null).collect( Collectors.toMap(IndicatorBottomFormMapper::getIndicatorId, IndicatorBottomFormMapper::getFormFieldId)); model.addAttribute("bottomFormMap", bottomFormMap); @@ -273,8 +276,7 @@ public class IndicatorController extends BaseController { (indicatorTopId == null ? (rootList.isEmpty() ? 0 : rootList.get(0).getId()) : indicatorTopId)); Map bottomCsvColumnMap = bottomCsvColumnList.stream() - .filter(a -> a.getCsvColumnId() != null) - .collect( + .filter(a -> a.getCsvColumnId() != null).collect( Collectors.toMap(IndicatorBottomCsvMapper::getIndicatorId, IndicatorBottomCsvMapper::getCsvColumnId)); model.addAttribute("bottomCsvColumnMap", bottomCsvColumnMap); @@ -322,7 +324,7 @@ public class IndicatorController extends BaseController { response.setContentType("text/csv; charset=UTF-8"); response.setHeader("Content-Disposition", "attachment; filename=\"" + java.net.URLEncoder.encode(csvFile.getCsvName(), - StandardCharsets.UTF_8) + "\""); + "utf-8") + "\""); // 写入文件流 try (OutputStream os = response.getOutputStream()) { @@ -423,4 +425,52 @@ public class IndicatorController extends BaseController { indicatorService.saveBottomMapper(mapperBean); return OperateResult.success(); } + + /** + * 批量导入. + * + * @param file 原始文件 + * @param parentId 父ID + * @param topId 根节点ID + * @return 操作结果 + */ + @PostMapping("/import") + @ResponseBody + public OperateResult importChildIndicator(@RequestParam("file") MultipartFile file, + Integer parentId, Integer topId) throws IOException { + StringBuilder sb = new StringBuilder(); + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(file.getInputStream(), StandardCharsets.UTF_8))) { + String line; + while ((line = reader.readLine()) != null) { + sb.append(line).append("\n"); + } + } + String content = sb.toString(); + Set duplicateSet = StringTool.checkDuplicates(content, "[,;\\n]"); + //本次记录有没有重复名称 + if (!duplicateSet.isEmpty()) { + return OperateResult.error(null, "存在重复的名称" + duplicateSet, + ErrorCode.BUSINESS_ERROR.getCode()); + } + content = content.replaceAll("\\s+", ""); + String[] childTextArray = content.split("[,;\\n]"); + //数据库中是否存在重名 + List exitList = indicatorService.selectByName(parentId, childTextArray); + if (!exitList.isEmpty()) { + StringBuffer tipsBuffer = new StringBuffer(); + exitList.forEach(item -> { + tipsBuffer.append(item.getName()).append(";"); + }); + return OperateResult.error(null, "存在重复的名称" + tipsBuffer, + ErrorCode.BUSINESS_ERROR.getCode()); + } + Long maxOrder = indicatorService.selectMaxOrderByParentId(parentId); + if (maxOrder == null) { + maxOrder = 9999L; + } + + indicatorService.batchImport(parentId, topId, maxOrder, childTextArray); + return OperateResult.success(); + } } diff --git a/manager-admin/src/main/java/com/hshh/indicator/controller/IndicatorSetController.java b/manager-admin/src/main/java/com/hshh/indicator/controller/IndicatorSetController.java index dd183e0..c531268 100644 --- a/manager-admin/src/main/java/com/hshh/indicator/controller/IndicatorSetController.java +++ b/manager-admin/src/main/java/com/hshh/indicator/controller/IndicatorSetController.java @@ -1,9 +1,13 @@ package com.hshh.indicator.controller; import com.hshh.indicator.bean.IndicatorSetBean; +import com.hshh.indicator.service.IndicatorTopLevelService; +import com.hshh.indicator.service.IndicatorTopSetService; +import com.hshh.system.annotation.LogOperation; import com.hshh.system.common.bean.BaseController; import com.hshh.system.common.bean.OperateResult; import io.swagger.v3.oas.annotations.tags.Tag; +import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -11,6 +15,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; /** * 指标全局函数设置. @@ -23,20 +28,34 @@ import org.springframework.web.bind.annotation.RequestMapping; @Tag(name = "指标全局函数设置", description = "指标全局函数设置") public class IndicatorSetController extends BaseController { + @Resource + private IndicatorTopLevelService topLevelService; + @Resource + private IndicatorTopSetService indicatorTopSetService; + /** * 指标全局函数默认设置页面. * - * @param model 数据容器 - * @param request 页面请求 + * @param model 数据容器 * @return indicator_set.html */ @GetMapping("/list") - public String list(Model model, HttpServletRequest request) { + @LogOperation("获取全局函数默认设置") + public String list(Model model) { setNavigateTitle(model, "/indicatorSet/list"); + IndicatorSetBean indicatorSetBean = new IndicatorSetBean(); + indicatorSetBean.setLevels(topLevelService.getTopLevel()); + indicatorSetBean.setTopSet(indicatorTopSetService.getIndicatorTopSet()); + model.addAttribute("indicatorSetBean", indicatorSetBean); return "system/indicator/indicator_set"; } - @PostMapping("/save") - public OperateResult save(@RequestBody IndicatorSetBean indicatorSetBean) { + @LogOperation("保存全局函数默认设置") + @PostMapping("/save") + @ResponseBody + public OperateResult save(@RequestBody IndicatorSetBean indicatorSetBean + ) { + topLevelService.saveWhole(indicatorSetBean); + return OperateResult.success(); } } diff --git a/manager-admin/src/main/java/com/hshh/indicator/entity/Indicator.java b/manager-admin/src/main/java/com/hshh/indicator/entity/Indicator.java index f4de6d6..c4c2b1a 100644 --- a/manager-admin/src/main/java/com/hshh/indicator/entity/Indicator.java +++ b/manager-admin/src/main/java/com/hshh/indicator/entity/Indicator.java @@ -29,9 +29,8 @@ public class Indicator extends CheckedBean { private Integer id; private Integer parentId; - @NotBlank(message = "编码不能为空") - @Size(max = 30, message = "编码不能超过30字符") - private String code; + + @NotBlank(message = "名称不能为空") @Size(max = 30, message = "名称不能超过30字符") private String name; diff --git a/manager-admin/src/main/java/com/hshh/indicator/mapper/IndicatorMapper.java b/manager-admin/src/main/java/com/hshh/indicator/mapper/IndicatorMapper.java index 288d60a..9dd2f05 100644 --- a/manager-admin/src/main/java/com/hshh/indicator/mapper/IndicatorMapper.java +++ b/manager-admin/src/main/java/com/hshh/indicator/mapper/IndicatorMapper.java @@ -28,4 +28,15 @@ public interface IndicatorMapper extends BaseMapper { * @return 指标列表 */ List selectByTemplateId(@Param("templateId") Integer templateId); + + /** + * 获取同一个父指标下最大顺序. + * + * @param parentId 父ID + * @return 当前最大顺序 + */ + Long selectMaxOrderByParentId(Integer parentId); + + List selectByName(@Param("parentId") Integer parentId, + @Param("nameList") String[] nameList); } diff --git a/manager-admin/src/main/java/com/hshh/indicator/service/IndicatorBottomFormMapperService.java b/manager-admin/src/main/java/com/hshh/indicator/service/IndicatorBottomFormMapperService.java index bfdd3fb..230b965 100644 --- a/manager-admin/src/main/java/com/hshh/indicator/service/IndicatorBottomFormMapperService.java +++ b/manager-admin/src/main/java/com/hshh/indicator/service/IndicatorBottomFormMapperService.java @@ -41,4 +41,5 @@ public interface IndicatorBottomFormMapperService extends IService selectIndicatorToFieldNameListByIndicatorTopId(Integer topId); + void deleteByFormFieldId(Integer formFieldId); } diff --git a/manager-admin/src/main/java/com/hshh/indicator/service/IndicatorFromMapperService.java b/manager-admin/src/main/java/com/hshh/indicator/service/IndicatorFromMapperService.java index 8ac017e..b9b12fc 100644 --- a/manager-admin/src/main/java/com/hshh/indicator/service/IndicatorFromMapperService.java +++ b/manager-admin/src/main/java/com/hshh/indicator/service/IndicatorFromMapperService.java @@ -36,4 +36,5 @@ public interface IndicatorFromMapperService extends IService { /** * 根据名称,ID,编码获取此ID所有的顶级指标下包含的指标的名称和编码是否有一致. * - * @param topId 指标ID(用于获取顶级父ID) + * @param parentId 父ID * @param name 名称 - * @param code 编码 + * @return 结果列表 */ - List queryList(Integer topId, String name, String code); + List queryList(Integer parentId, String name); /** * 获取所有的根指标. @@ -42,7 +42,7 @@ public interface IndicatorService extends IService { * @param id 指定ID * @return 对应指标 */ - Indicator getIndicator(Integer id); + Indicator getRecursionIndicator(Integer id); /** * 根据父节点查询直接孩子. @@ -109,5 +109,33 @@ public interface IndicatorService extends IService { */ Indicator selectByTemplateId(@Param("templateId") Integer templateId); + /** + * 获取同一个父指标下最大顺序. + * + * @param parentId 父ID + * @return 当前最大顺序 + */ + Long selectMaxOrderByParentId(Integer parentId); + + /** + * 批量导入子指标. + * + * @param parentId 父ID + * @param topId 根ID + * @param maxOrder 最大顺序,当前父指标下 + * @param children 子指标名称 + */ + void batchImport(Integer parentId, Integer topId, Long maxOrder, String[] children); + + /** + * 查看同一个父ID下是否重名. + * + * @param parentId 父ID + * @param nameList 名称列表 + * @return 存在记录 + */ + List selectByName(@Param("parentId") Integer parentId, + @Param("nameList") String[] nameList); + void deleteIndicator(Integer id) throws Exception; } diff --git a/manager-admin/src/main/java/com/hshh/indicator/service/impl/IndicatorBottomMapperServiceImpl.java b/manager-admin/src/main/java/com/hshh/indicator/service/impl/IndicatorBottomMapperServiceImpl.java index 862f24e..5964563 100644 --- a/manager-admin/src/main/java/com/hshh/indicator/service/impl/IndicatorBottomMapperServiceImpl.java +++ b/manager-admin/src/main/java/com/hshh/indicator/service/impl/IndicatorBottomMapperServiceImpl.java @@ -46,4 +46,11 @@ public class IndicatorBottomMapperServiceImpl extends public List selectIndicatorToFieldNameListByIndicatorTopId(Integer topId) { return this.baseMapper.selectByIndicatorTopId(topId); } + + @Override + public void deleteByFormFieldId(Integer formFieldId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("form_field_id", formFieldId); + remove(queryWrapper); + } } diff --git a/manager-admin/src/main/java/com/hshh/indicator/service/impl/IndicatorFormMapperServiceImpl.java b/manager-admin/src/main/java/com/hshh/indicator/service/impl/IndicatorFormMapperServiceImpl.java index 6f83fb3..9317f98 100644 --- a/manager-admin/src/main/java/com/hshh/indicator/service/impl/IndicatorFormMapperServiceImpl.java +++ b/manager-admin/src/main/java/com/hshh/indicator/service/impl/IndicatorFormMapperServiceImpl.java @@ -41,4 +41,11 @@ public class IndicatorFormMapperServiceImpl extends this.baseMapper.delete(queryWrapper); } + + @Override + public void deleteByModelId(Integer modelId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("indicator_model_id", modelId); + remove(queryWrapper); + } } diff --git a/manager-admin/src/main/java/com/hshh/indicator/service/impl/IndicatorServiceImpl.java b/manager-admin/src/main/java/com/hshh/indicator/service/impl/IndicatorServiceImpl.java index 4f10026..075ee91 100644 --- a/manager-admin/src/main/java/com/hshh/indicator/service/impl/IndicatorServiceImpl.java +++ b/manager-admin/src/main/java/com/hshh/indicator/service/impl/IndicatorServiceImpl.java @@ -12,18 +12,21 @@ import com.hshh.indicator.service.IndicatorCsvColumnService; import com.hshh.indicator.service.IndicatorCsvService; import com.hshh.indicator.service.IndicatorService; import com.hshh.system.common.bean.JsTree; +import com.hshh.system.common.util.FileUtil; import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.nio.charset.StandardCharsets; +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import javax.annotation.Resource; -import javax.validation.constraints.NotNull; -import org.apache.commons.csv.CSVFormat; -import org.apache.commons.csv.CSVParser; +import org.mybatis.spring.SqlSessionTemplate; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; @@ -40,6 +43,8 @@ import org.springframework.web.multipart.MultipartFile; public class IndicatorServiceImpl extends ServiceImpl implements IndicatorService { + @Autowired + private SqlSessionTemplate sqlSessionTemplate; @Resource private IndicatorCsvService csvService; @Resource @@ -56,13 +61,13 @@ public class IndicatorServiceImpl extends ServiceImpl queryList(@NotNull Integer topId, @NotNull String name, - @NotNull String code) { + public List queryList(Integer parentId, String name + ) { QueryWrapper queryWrapper = new QueryWrapper<>(); - if (topId != null) { - queryWrapper.eq("top_id", topId); + if (parentId != null) { + queryWrapper.eq("parent_id", parentId); } - queryWrapper.and(wrapper -> wrapper.eq("name", name).or().eq("code", code)); + queryWrapper.and(wrapper -> wrapper.eq("name", name)); return this.list(queryWrapper); } @@ -70,13 +75,14 @@ public class IndicatorServiceImpl extends ServiceImpl queryRootList() { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.isNull("parent_id"); + queryWrapper.eq("parent_id", 0); + queryWrapper.orderByAsc("sort_order"); return this.list(queryWrapper); } @Override - public Indicator getIndicator(Integer id) { + public Indicator getRecursionIndicator(Integer id) { Indicator indicator = this.getById(id); Map> map = this.list().stream() .collect(Collectors.groupingBy(a -> a.getParentId() == null ? 0 : a.getParentId())); @@ -118,22 +124,23 @@ public class IndicatorServiceImpl extends ServiceImpl saveIndicatorTopCsvMapper(Integer topId, MultipartFile file) throws IOException { - Reader reader = new InputStreamReader(file.getInputStream(), StandardCharsets.UTF_8); - CSVParser parser = CSVFormat.DEFAULT.builder().setHeader() // 表示第一行是表头 - .setSkipHeaderRecord(true) // 解析时跳过表头行 - .build().parse(reader); - ArrayList headerList = new ArrayList<>(parser.getHeaderMap().keySet()); - if (headerList.isEmpty()) { - return null; + + List> contentList = FileUtil.parseCsvFromInputStream(file); + if (!contentList.isEmpty()) { + List headerList = contentList.get(0); + if (headerList.isEmpty()) { + return null; + } + //删除表中m_data_indicator_csv原来topID对应记录 + csvService.removeByIndicatorId(topId); + //添加m_data_indicator_csv记录 + Integer csvId = csvService.saveCsv(topId, file.getBytes(), file.getOriginalFilename()); + //删除m_data_indicator_csv_column 原topID对应的记录 + csvColumnService.deleteByTopId(topId); + //添加对应记录 + return csvColumnService.save(headerList, topId, csvId); } - //删除表中m_data_indicator_csv原来topID对应记录 - csvService.removeByIndicatorId(topId); - //添加m_data_indicator_csv记录 - Integer csvId = csvService.saveCsv(topId, file.getBytes(), file.getOriginalFilename()); - //删除m_data_indicator_csv_column 原topID对应的记录 - csvColumnService.deleteByTopId(topId); - //添加对应记录 - return csvColumnService.save(headerList, topId, csvId); + return null; } /** @@ -159,7 +166,7 @@ public class IndicatorServiceImpl extends ServiceImpl metricTree(Integer topId) { - Indicator top = getIndicator(topId); + Indicator top = getRecursionIndicator(topId); List rootList = new ArrayList<>(); rootList.add(top); @@ -197,5 +204,92 @@ public class IndicatorServiceImpl extends ServiceImpl selectByName(Integer parentId, String[] nameList) { + return this.baseMapper.selectByName(parentId, nameList); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteIndicator(Integer id) throws SQLException { + Indicator indicator = getRecursionIndicator(id); + Set idList = new HashSet<>(); + fillIndicatorList(idList, indicator); + + Connection connection = sqlSessionTemplate.getConnection(); + List sqlList = new ArrayList<>(); + for (int i = 1; i < idList.size(); i++) { + + } + idList.forEach(indicatorId -> { + if (!Objects.equals(indicatorId, id)) { + addSql(sqlList, indicatorId); + } + }); + addSql(sqlList, id); + + try (Statement ste = connection.createStatement()) { + for (String sql : sqlList) { + ste.addBatch(sql); + } + ste.executeBatch(); + } catch (SQLException e) { + throw e; // 触发 Spring 事务自动回滚 + } + } + + private void addSql(List sqlList, Integer id) { + sqlList.add( + "delete from m_data_evaluation_indicator_result where indicator_id = " + id); + sqlList.add("delete from m_data_evaluation_template_indicator_weight where indicator_id = " + + id); + sqlList.add( + "delete from m_data_evaluation_template_weight where from_indicator_id = " + id + + " or to_indicator_id=" + id); + sqlList.add("delete from m_data_evaluation_template_weight_detail where from_indicator_id=" + + id + " or to_indicator_id=" + id); + sqlList.add( + "delete from m_data_indicator_bottom_csv_mapper where indicator_id=" + id); + sqlList.add( + "delete from m_data_indicator_bottom_form_mapper where indicator_id=" + id); + sqlList.add("delete from m_data_indicator_eval_item where indicator_id=" + id); + sqlList.add("delete from m_data_evaluation_template where indicator_top_id=" + id); + sqlList.add( + "delete from m_data_evaluation_root_result where indicator_top_id=" + id); + sqlList.add("delete from m_data_indicator_form where indicator_top_id=" + id); + sqlList.add("delete from m_data_indicator_weight where indicator_id=" + id); + sqlList.add( + "delete from m_data_indicator_csv_column where indicator_top_id=" + id); + sqlList.add("delete from m_data_indicator_csv where indicator_top_id=" + id); + sqlList.add("delete from m_data_indicator where id=" + id); + } + + private void fillIndicatorList(Set idList, Indicator indicator) { + idList.add(indicator.getId()); + if (indicator.getChildren() != null) { + indicator.getChildren().forEach(child -> { + fillIndicatorList(idList, child); + }); + } + } } diff --git a/manager-admin/src/main/java/com/hshh/model/controller/ModelDefineController.java b/manager-admin/src/main/java/com/hshh/model/controller/ModelDefineController.java index 8d9e3b7..ad7c12f 100644 --- a/manager-admin/src/main/java/com/hshh/model/controller/ModelDefineController.java +++ b/manager-admin/src/main/java/com/hshh/model/controller/ModelDefineController.java @@ -192,20 +192,8 @@ public class ModelDefineController extends BaseController { @Operation(summary = "删除数据模型", description = "根据ID删除数据模型") @ResponseBody public OperateResult removeModelDefine(@PathVariable("id") Integer id) { - //查看是否有字段,若有字段,则无法删除 - List fieldList = formFieldConfigService.getFormFieldConfigByModelId(id); - if (fieldList != null && !fieldList.isEmpty()) { - return OperateResult.error(null, ErrorMessage.OBJ_HAS_SUB.getMessage(), - ErrorCode.BUSINESS_ERROR.getCode()); - } - //查看数据关联表是否有记录 - List relList = tableRelationsService.queryRel(id, - "m_data_model_define"); - if (relList != null && !relList.isEmpty()) { - return OperateResult.error(null, ErrorMessage.OBJ_ALREADY_TAKEN.getMessage(), - ErrorCode.BUSINESS_ERROR.getCode()); - } - modelDefineService.removeById(id); + + modelDefineService.deleteTheWholeModel(id); return OperateResult.success(); } diff --git a/manager-admin/src/main/java/com/hshh/model/service/FormFieldConfigService.java b/manager-admin/src/main/java/com/hshh/model/service/FormFieldConfigService.java index 1ae1aab..40223b5 100644 --- a/manager-admin/src/main/java/com/hshh/model/service/FormFieldConfigService.java +++ b/manager-admin/src/main/java/com/hshh/model/service/FormFieldConfigService.java @@ -41,4 +41,5 @@ public interface FormFieldConfigService extends IService { * @return 字段map */ Map getHeaderMap(Integer modelId); + void deleteByModelId(Integer modelId); } diff --git a/manager-admin/src/main/java/com/hshh/model/service/FormValueService.java b/manager-admin/src/main/java/com/hshh/model/service/FormValueService.java index ec7022e..7587b40 100644 --- a/manager-admin/src/main/java/com/hshh/model/service/FormValueService.java +++ b/manager-admin/src/main/java/com/hshh/model/service/FormValueService.java @@ -36,4 +36,5 @@ public interface FormValueService extends IService { * @return 结果列表 */ List selectByIds(List ids); + void deleteFromByModelId(Integer id); } diff --git a/manager-admin/src/main/java/com/hshh/model/service/ModelDefineService.java b/manager-admin/src/main/java/com/hshh/model/service/ModelDefineService.java index ee664e3..ea3042d 100644 --- a/manager-admin/src/main/java/com/hshh/model/service/ModelDefineService.java +++ b/manager-admin/src/main/java/com/hshh/model/service/ModelDefineService.java @@ -20,7 +20,7 @@ public interface ModelDefineService extends IService { * @param modelCode 模型编码 * @return 模型 */ - public ModelDefine getModelDefineByModelCodeOrName(String modelName, String modelCode); - + ModelDefine getModelDefineByModelCodeOrName(String modelName, String modelCode); + void deleteTheWholeModel(Integer id); } diff --git a/manager-admin/src/main/java/com/hshh/model/service/impl/FormFieldConfigServiceImpl.java b/manager-admin/src/main/java/com/hshh/model/service/impl/FormFieldConfigServiceImpl.java index 048b9d1..1f60601 100644 --- a/manager-admin/src/main/java/com/hshh/model/service/impl/FormFieldConfigServiceImpl.java +++ b/manager-admin/src/main/java/com/hshh/model/service/impl/FormFieldConfigServiceImpl.java @@ -48,4 +48,11 @@ public class FormFieldConfigServiceImpl extends }); return headerMap; } + + @Override + public void deleteByModelId(Integer modelId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("data_model_id", modelId); + remove(queryWrapper); + } } diff --git a/manager-admin/src/main/java/com/hshh/model/service/impl/FormValueServiceImpl.java b/manager-admin/src/main/java/com/hshh/model/service/impl/FormValueServiceImpl.java index f19410d..f773874 100644 --- a/manager-admin/src/main/java/com/hshh/model/service/impl/FormValueServiceImpl.java +++ b/manager-admin/src/main/java/com/hshh/model/service/impl/FormValueServiceImpl.java @@ -1,5 +1,6 @@ package com.hshh.model.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hshh.model.entity.FormValue; import com.hshh.model.mapper.FormValueMapper; @@ -32,4 +33,11 @@ public class FormValueServiceImpl extends ServiceImpl selectByIds(List ids) { return this.baseMapper.selectByIds(ids); } + + @Override + public void deleteFromByModelId(Integer id) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("model_define_id",id); + remove(queryWrapper); + } } diff --git a/manager-admin/src/main/java/com/hshh/model/service/impl/ModelDefineServiceImpl.java b/manager-admin/src/main/java/com/hshh/model/service/impl/ModelDefineServiceImpl.java index 3411088..af7feff 100644 --- a/manager-admin/src/main/java/com/hshh/model/service/impl/ModelDefineServiceImpl.java +++ b/manager-admin/src/main/java/com/hshh/model/service/impl/ModelDefineServiceImpl.java @@ -2,12 +2,18 @@ package com.hshh.model.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hshh.indicator.service.IndicatorBottomFormMapperService; +import com.hshh.indicator.service.IndicatorFromMapperService; import com.hshh.model.entity.FormFieldConfig; import com.hshh.model.entity.ModelDefine; import com.hshh.model.mapper.ModelDefineMapper; +import com.hshh.model.service.FormFieldConfigService; +import com.hshh.model.service.FormValueService; import com.hshh.model.service.ModelDefineService; import java.util.List; +import javax.annotation.Resource; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; /** * 服务实现类. @@ -19,6 +25,14 @@ import org.springframework.stereotype.Service; public class ModelDefineServiceImpl extends ServiceImpl implements ModelDefineService { + @Resource + private FormFieldConfigService formFieldConfigService; + @Resource + private FormValueService formValueService; + @Resource + private IndicatorBottomFormMapperService indicatorBottomFormMapperService; + @Resource + private IndicatorFromMapperService indicatorFromMapperService; @Override public ModelDefine getModelDefineByModelCodeOrName(String modelName, String modelCode) { @@ -28,5 +42,18 @@ public class ModelDefineServiceImpl extends ServiceImpl fieldList = formFieldConfigService.getFormFieldConfigByModelId(id); + fieldList.forEach(field -> { + indicatorBottomFormMapperService.deleteByFormFieldId(field.getId()); + }); + formValueService.deleteFromByModelId(id); + formFieldConfigService.deleteByModelId(id); + indicatorFromMapperService.deleteByModelId(id); + this.removeById(id); + } } diff --git a/manager-admin/src/main/resources/application.yaml b/manager-admin/src/main/resources/application.yaml index dd34e14..f06a854 100644 --- a/manager-admin/src/main/resources/application.yaml +++ b/manager-admin/src/main/resources/application.yaml @@ -1,9 +1,22 @@ server: - port: 8088 + port: 8188 +# SSL: +# key-store: classpath:keystore.p12 +# key-store-password: 123456 +# key-store-type: PKCS12 +# servlet: +# session: +# cookie: +# same-site: none +# secure: true spring: thymeleaf: cache: false datasource: +# url: jdbc:dm://192.168.0.53:5236/MANAGER +# username: sysdba +# password: Admin123 +# driver-class-name: dm.jdbc.driver.DmDriver url: jdbc:mysql://localhost:3306/manager?allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC username: root password: 123456 @@ -27,7 +40,7 @@ mybatis-plus: mapper-locations: classpath*:/mapper/**/*.xml configuration: - database-id: mysql + database-id: dm # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl diff --git a/manager-admin/src/main/resources/indicator_set.yaml b/manager-admin/src/main/resources/indicator_set.yaml new file mode 100644 index 0000000..611a9f3 --- /dev/null +++ b/manager-admin/src/main/resources/indicator_set.yaml @@ -0,0 +1,26 @@ +indicator: + default: + levels: + - levelName: 优 + grade: 90 + levelOrder: 1 + equalValue: 优 + + - levelName: 良 + grade: 80 + levelOrder: 2 + equalValue: 良 + - levelName: 可 + grade: 70 + levelOrder: 3 + equalValue: 可 + - levelName: 差 + grade: 60 + levelOrder: 4 + equalValue: 差 + function: + membershipFunc: TRAP_TRI + softEdgeS: 0.10 + triangleOverlapRatio: 0.01 + trianglePeakRatio: 0.01 + method: PRODUCT_BOUNDED_SUM \ No newline at end of file diff --git a/manager-admin/src/main/resources/mapper/EvaluationProjectMapper.xml b/manager-admin/src/main/resources/mapper/EvaluationProjectMapper.xml index 1795b27..e72cf28 100644 --- a/manager-admin/src/main/resources/mapper/EvaluationProjectMapper.xml +++ b/manager-admin/src/main/resources/mapper/EvaluationProjectMapper.xml @@ -17,15 +17,16 @@ #{start},#{pageSize} + + diff --git a/manager-admin/src/main/resources/static/img/help/root_add.png b/manager-admin/src/main/resources/static/img/help/root_add.png new file mode 100644 index 0000000..cbf62b4 Binary files /dev/null and b/manager-admin/src/main/resources/static/img/help/root_add.png differ diff --git a/manager-admin/src/main/resources/static/img/help/root_add_1.png b/manager-admin/src/main/resources/static/img/help/root_add_1.png new file mode 100644 index 0000000..a379d6e Binary files /dev/null and b/manager-admin/src/main/resources/static/img/help/root_add_1.png differ diff --git a/manager-admin/src/main/resources/static/img/help/root_add_2.png b/manager-admin/src/main/resources/static/img/help/root_add_2.png new file mode 100644 index 0000000..4370ef0 Binary files /dev/null and b/manager-admin/src/main/resources/static/img/help/root_add_2.png differ diff --git a/manager-admin/src/main/resources/static/img/undraw_bug_fixing_oc7a.svg b/manager-admin/src/main/resources/static/img/undraw_bug_fixing_oc7a.svg deleted file mode 100644 index 867f5a2..0000000 --- a/manager-admin/src/main/resources/static/img/undraw_bug_fixing_oc7a.svg +++ /dev/null @@ -1 +0,0 @@ -bug fixing \ No newline at end of file diff --git a/manager-admin/src/main/resources/static/img/undraw_logistics.svg b/manager-admin/src/main/resources/static/img/undraw_logistics.svg deleted file mode 100644 index d74057b..0000000 --- a/manager-admin/src/main/resources/static/img/undraw_logistics.svg +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/manager-admin/src/main/resources/static/img/undraw_personal-goals_f9bb.svg b/manager-admin/src/main/resources/static/img/undraw_personal-goals_f9bb.svg new file mode 100644 index 0000000..c3c2baf --- /dev/null +++ b/manager-admin/src/main/resources/static/img/undraw_personal-goals_f9bb.svg @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/manager-admin/src/main/resources/templates/faq.html b/manager-admin/src/main/resources/templates/faq.html new file mode 100644 index 0000000..346c2b1 --- /dev/null +++ b/manager-admin/src/main/resources/templates/faq.html @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+
+

使用帮助

+
+

1. 如何建立指标?

+
+
+ +
+
+
+

点击菜单[评估指标管理/指标体系],建立根指标,如图 :

+ 评估指标管理菜单截图 +

+

点击新增后如图:

+ 评估指标管理菜单截图 +

+

成功添加后显示

+ 评估指标管理菜单截图 +

+

根指标建立完成,接着可以对根指标建立下级指标

+
+
+
+
+
+ +
+
+
+

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusantium alias dignissimos dolorum ea est eveniet, excepturi illum in iste iure maiores nemo recusandae rerum saepe sed, sunt totam! Explicabo, ipsa?

+

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusantium alias dignissimos dolorum ea est eveniet, excepturi illum in iste iure maiores nemo recusandae rerum saepe sed, sunt totam! Explicabo, ipsa?

+
+
+
+
+
+ +
+
+
+

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusantium alias dignissimos dolorum ea est eveniet, excepturi illum in iste iure maiores nemo recusandae rerum saepe sed, sunt totam! Explicabo, ipsa?

+

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusantium alias dignissimos dolorum ea est eveniet, excepturi illum in iste iure maiores nemo recusandae rerum saepe sed, sunt totam! Explicabo, ipsa?

+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/manager-admin/src/main/resources/templates/fragments/header.html b/manager-admin/src/main/resources/templates/fragments/header.html index 0479786..f1c860d 100644 --- a/manager-admin/src/main/resources/templates/fragments/header.html +++ b/manager-admin/src/main/resources/templates/fragments/header.html @@ -6,11 +6,13 @@
-
+
+
+ - \ No newline at end of file + diff --git a/manager-admin/src/main/resources/templates/home.html b/manager-admin/src/main/resources/templates/home.html index 6145147..d113a03 100644 --- a/manager-admin/src/main/resources/templates/home.html +++ b/manager-admin/src/main/resources/templates/home.html @@ -12,94 +12,117 @@ + - + @@ -245,9 +395,14 @@
+
+ empty +

+
+
@@ -258,6 +413,11 @@
+ + + + + @@ -271,17 +431,25 @@ diff --git a/manager-admin/src/main/resources/templates/indicator/add_indicator.html b/manager-admin/src/main/resources/templates/indicator/add_indicator.html index 16aa86a..ec00f4d 100644 --- a/manager-admin/src/main/resources/templates/indicator/add_indicator.html +++ b/manager-admin/src/main/resources/templates/indicator/add_indicator.html @@ -12,12 +12,7 @@
-
- - -
-
+ diff --git a/manager-admin/src/main/resources/templates/indicator/evaluation_list.html b/manager-admin/src/main/resources/templates/indicator/evaluation_list.html index 7cf4506..23cb0bd 100644 --- a/manager-admin/src/main/resources/templates/indicator/evaluation_list.html +++ b/manager-admin/src/main/resources/templates/indicator/evaluation_list.html @@ -6,7 +6,7 @@
- +
@@ -76,8 +76,8 @@ 等级名 - 上限 - 下限 + 上限(包含) + 下限(不包含) 等于 @@ -195,6 +195,7 @@ let topTd = document.createElement("td"); let topInput = document.createElement("input"); topInput.type = "number"; + topInput.value=0 topInput.style.width = "8ch"; topInput.addEventListener("change", function () { inputChange(); @@ -207,6 +208,7 @@ let bottomTd = document.createElement("td"); let bottomInput = document.createElement("input"); bottomInput.type = "number"; + bottomInput.value = 0; bottomInput.style.width = "8ch"; bottomInput.addEventListener("change", function () { inputChange() @@ -224,7 +226,7 @@ equalValueInput.addEventListener("change", function () { inputChange(); }); - if (historyMap.get(equalValueTd.textContent)) { + if (historyMap.get(td.textContent)) { equalValueInput.value = historyMap.get(td.textContent).equalValue; } equalValueTd.appendChild(equalValueInput); diff --git a/manager-admin/src/main/resources/templates/indicator/indicator_mapper.html b/manager-admin/src/main/resources/templates/indicator/indicator_mapper.html index ce67b17..46d1a48 100644 --- a/manager-admin/src/main/resources/templates/indicator/indicator_mapper.html +++ b/manager-admin/src/main/resources/templates/indicator/indicator_mapper.html @@ -37,18 +37,22 @@
1. 选择指标(根指标)
+
选择根指标后,再选择设施与 CSV + 以建立映射。 +
-
-
选择根指标后,再选择设施与 CSV 以建立映射。
+
@@ -81,10 +85,10 @@
3. 上传 CSV 文件
- +
上传文件,根据表头对应指标
- 未选择文件 - + +
上次上传文件: @@ -104,10 +108,21 @@
4. 子指标映射设置
+ +
+
+ 说明:为每个子指标选择表单字段或 CSV 列,系统会保存映射关系用于后续处理。 +
- +
@@ -117,14 +132,16 @@ - + - +
#
+
-
- 说明:为每个子指标选择表单字段或 CSV 列,系统会保存映射关系用于后续处理。 -
+
@@ -162,6 +178,33 @@ \ No newline at end of file diff --git a/manager-admin/src/main/resources/templates/system/indicator/indicator_set.html b/manager-admin/src/main/resources/templates/system/indicator/indicator_set.html index 5757039..4ccb442 100644 --- a/manager-admin/src/main/resources/templates/system/indicator/indicator_set.html +++ b/manager-admin/src/main/resources/templates/system/indicator/indicator_set.html @@ -30,66 +30,102 @@ 等级名 代表分 + 代表值 - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -99,7 +135,7 @@
-
+
2.全局默认隶属函数设置
@@ -110,9 +146,9 @@
@@ -122,7 +158,7 @@
@@ -133,7 +169,7 @@
@@ -143,7 +179,7 @@
@@ -152,6 +188,31 @@
+
+
+
3.模糊运算方式
+
+
+
+
+
+ +
+ +
+
+ +
+
+
+
@@ -168,23 +229,31 @@ function saveIndicatorGlobalSet(){ let levelGradeList = []; let levelNames = document.getElementsByName("_level"); let grades = document.getElementsByName("_score"); + let equalValues = document.getElementsByName("_equalValue"); for (let i = 0; i < levelNames.length; i++) { let level = {}; level.levelName = levelNames[i].value; - level.indicatorTopId = parseInt(obj.indicatorTopId); level.grade = parseInt(grades[i].value); + level.equalValue = (equalValues[i].value); levelGradeList.push(level); } - obj.topLevel = levelGradeList; - //获取顶级指标隶属函数设置 + //评价集设置 + obj.levels = levelGradeList; + let membership = {}; - membership.indicatorTopId = obj.indicatorTopId; + membership.membershipFunc = document.getElementById("_membershipFunc").value; membership.softEdgeS = document.getElementById("softEdgeS").value; membership.triangleOverlapRatio = document.getElementById("triangleOverlapRatio").value; membership.trianglePeakRatio = document.getElementById("trianglePeakRatio").value; + membership.method = document.getElementById("_method").value; + //级指标隶属函数设置 obj.topSet = membership; - + let url = document.getElementById("_rootPath").value+"indicatorSet/save" + let http = new HttpClient(); + http.post(url, obj,function (error,res,xhr) { + showAlert("success","保存成功") + },null,null) } \ No newline at end of file diff --git a/manager-admin/src/main/resources/templates/system/log/list.html b/manager-admin/src/main/resources/templates/system/log/list.html index 6a02b07..7343eb7 100644 --- a/manager-admin/src/main/resources/templates/system/log/list.html +++ b/manager-admin/src/main/resources/templates/system/log/list.html @@ -58,7 +58,7 @@
- +
@@ -82,7 +82,7 @@ - + diff --git a/manager-admin/src/main/resources/templates/system/user/add.html b/manager-admin/src/main/resources/templates/system/user/add.html index 2e28942..402588c 100644 --- a/manager-admin/src/main/resources/templates/system/user/add.html +++ b/manager-admin/src/main/resources/templates/system/user/add.html @@ -48,7 +48,7 @@
-
昵称
+
昵称
diff --git a/manager-system/pom.xml b/manager-system/pom.xml index 1377e24..5459fd3 100644 --- a/manager-system/pom.xml +++ b/manager-system/pom.xml @@ -79,16 +79,21 @@ org.springframework.boot spring-boot-starter-websocket - + org.springframework.boot spring-boot-starter-aop - + org.springframework spring-context-support + + com + dmjdbc + + diff --git a/manager-system/src/main/java/com/hshh/system/algorithm/ahp/AhpTreeCompute.java b/manager-system/src/main/java/com/hshh/system/algorithm/ahp/AhpTreeCompute.java index 8321683..a2291cf 100644 --- a/manager-system/src/main/java/com/hshh/system/algorithm/ahp/AhpTreeCompute.java +++ b/manager-system/src/main/java/com/hshh/system/algorithm/ahp/AhpTreeCompute.java @@ -52,16 +52,7 @@ public class AhpTreeCompute { * 打印树(缩进展示),显示局部/全局权重与一致性 */ static void printTree(AhpNode node, int depth) { - String indent = " ".repeat(depth); - String info = String.format("%s- %s (global=%.4f)", indent, node.name, - Double.isNaN(node.globalWeight) ? 0.0 : node.globalWeight); - - - - for (AhpNode c : node.children) { - printTree(c, depth + 1); - } } // ---------------- 完整示例 ---------------- diff --git a/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/EvaluationLevel.java b/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/EvaluationLevel.java index 2252209..35c9c0b 100644 --- a/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/EvaluationLevel.java +++ b/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/EvaluationLevel.java @@ -12,11 +12,15 @@ package com.hshh.system.algorithm.fuzzy; // 评价等级定义类 public class EvaluationLevel { private String levelName; + //分值 private double score; + //相等值 + private String equalValue; - public EvaluationLevel(String levelName, double score) { + public EvaluationLevel(String levelName, double score, String equalValue) { this.levelName = levelName; this.score = score; + this.equalValue = equalValue; } public String getLevelName() { return levelName; } diff --git a/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/FuzzyEvaluationService.java b/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/FuzzyEvaluationService.java index b5774c7..d5bf988 100644 --- a/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/FuzzyEvaluationService.java +++ b/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/FuzzyEvaluationService.java @@ -15,6 +15,7 @@ import java.util.Map; * @since 2025/7/22 */ public class FuzzyEvaluationService { + private GlobalEvaluationConfig globalConfig; public FuzzyEvaluationService(GlobalEvaluationConfig globalConfig) { @@ -37,8 +38,15 @@ public class FuzzyEvaluationService { calculateScore(node); } + /** + * 计算叶子界的点的隶属度. + * + * @param node 叶子节点 + */ private void calculateLeafNodeMembership(IndicatorNode node) { + if (node.getActualValue() != null && node.getMembershipFunction() != null) { + Map membership = node.getMembershipFunction() .calculateMembership(node.getActualValue()); node.setMembershipDegrees(membership); @@ -69,7 +77,8 @@ public class FuzzyEvaluationService { } // 修正:添加归一化处理 - if (operator == FuzzyOperator.MIN_BOUNDED_SUM || operator == FuzzyOperator.PRODUCT_BOUNDED_SUM) { + if (operator == FuzzyOperator.MIN_BOUNDED_SUM + || operator == FuzzyOperator.PRODUCT_BOUNDED_SUM) { normalizeMembership(combinedMembership); } @@ -146,47 +155,9 @@ public class FuzzyEvaluationService { } public void printEvaluationResult(IndicatorNode root) { - System.out.println("=== 模糊综合评价结果 ==="); - System.out.println("全局评价等级和代表分:"); - for (EvaluationLevel level : globalConfig.getEvaluationLevels()) { - System.out.println(" " + level.getLevelName() + ": " + level.getScore()); - } - System.out.println(); - printNodeResult(root, 0); + + } - private void printNodeResult(IndicatorNode node, int level) { - String indent = " ".repeat(level); - System.out.println(indent + "节点: " + node.getName() + " (ID: " + node.getId() + ")"); - if (node.getWeight() != null) { - System.out.println(indent + "权重: " + String.format("%.4f", node.getWeight())); - } - if (node.getActualValue() != null) { - System.out.println(indent + "实际值: " + node.getActualValue()); - } - if (node.getMembershipFunction() != null) { - System.out.println(indent + "隶属函数类型: " + node.getMembershipFunction().getType()); - } - - System.out.println(indent + "隶属度: "); - // 修正:显示隶属度总和用于调试 - double totalMembership = 0.0; - for (String levelName : globalConfig.getAllLevelNames()) { - double degree = node.getMembershipDegrees().getOrDefault(levelName, 0.0); - totalMembership += degree; - System.out.println(indent + " " + levelName + ": " + String.format("%.4f", degree)); - } - System.out.println(indent + " 总和: " + String.format("%.4f", totalMembership)); - - if (node.getScore() != null) { - System.out.println(indent + "综合分值: " + String.format("%.2f", node.getScore())); - } - - System.out.println(indent + "---"); - - for (IndicatorNode child : node.getChildren()) { - printNodeResult(child, level + 1); - } - } } diff --git a/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/FuzzyEvaluationTest.java b/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/FuzzyEvaluationTest.java index 69f105e..9510291 100644 --- a/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/FuzzyEvaluationTest.java +++ b/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/FuzzyEvaluationTest.java @@ -14,11 +14,11 @@ public class FuzzyEvaluationTest { public static void main(String[] args) { // 创建全局评价配置 List evaluationLevels = Arrays.asList( - new EvaluationLevel("差", 40.0), - new EvaluationLevel("及格", 60.0), - new EvaluationLevel("中", 70.0), - new EvaluationLevel("良", 80.0), - new EvaluationLevel("优", 90.0) + new EvaluationLevel("差", 40.0,""), + new EvaluationLevel("及格", 60.0,""), + new EvaluationLevel("中", 70.0,""), + new EvaluationLevel("良", 80.0,""), + new EvaluationLevel("优", 90.0,"") ); GlobalEvaluationConfig globalConfig = new GlobalEvaluationConfig(evaluationLevels); @@ -75,19 +75,19 @@ public class FuzzyEvaluationTest { // 修正:调整底部指标的评价区间,使其更合理 List chineseRanges = Arrays.asList( - new GradeRange("差", 0, 60), - new GradeRange("及格", 60, 70), - new GradeRange("中", 70, 80), // 调整回原来的区间 - new GradeRange("良", 80, 90), // 88分应该在这个区间有较高隶属度 - new GradeRange("优", 90, 100) + new GradeRange("差", 0, 60,""), + new GradeRange("及格", 60, 70,""), + new GradeRange("中", 70, 80,""), // 调整回原来的区间 + new GradeRange("良", 80, 90,""), // 88分应该在这个区间有较高隶属度 + new GradeRange("优", 90, 100,"") ); List englishRanges = Arrays.asList( - new GradeRange("差", 0, 60), - new GradeRange("及格", 60, 70), - new GradeRange("中", 70, 80), // 调整回原来的区间 - new GradeRange("良", 80, 90), // 88分应该在这个区间有较高隶属度 - new GradeRange("优", 90, 100) + new GradeRange("差", 0, 60,""), + new GradeRange("及格", 60, 70,""), + new GradeRange("中", 70, 80,""), // 调整回原来的区间 + new GradeRange("良", 80, 90,""), // 88分应该在这个区间有较高隶属度 + new GradeRange("优", 90, 100,"") ); diff --git a/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/GlobalMembershipFunction.java b/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/GlobalMembershipFunction.java index 366eb4b..e01ca63 100644 --- a/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/GlobalMembershipFunction.java +++ b/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/GlobalMembershipFunction.java @@ -14,6 +14,7 @@ import java.util.Map; * @since 2025/7/22 */ public class GlobalMembershipFunction implements MembershipFunction { + private String functionType; private double overlapRatio; private double peakRatio; @@ -31,7 +32,7 @@ public class GlobalMembershipFunction implements MembershipFunction { } @Override - public Map calculateMembership(double value) { + public Map calculateMembership(Object value) { Map membership = new HashMap<>(); List levelNames = globalConfig.getAllLevelNames(); @@ -42,14 +43,14 @@ public class GlobalMembershipFunction implements MembershipFunction { if ("TRAP_TRI".equals(functionType)) { if (i == 0) { - degree = calculateLeftTrapezoid(value, scores, i); + degree = calculateLeftTrapezoid((Double) value, scores, i); } else if (i == levelNames.size() - 1) { - degree = calculateRightTrapezoid(value, scores, i); + degree = calculateRightTrapezoid((Double) value, scores, i); } else { - degree = calculateTriangle(value, scores, i); + degree = calculateTriangle((Double) value, scores, i); } } else { - degree = calculateTriangle(value, scores, i); + degree = calculateTriangle((Double) value, scores, i); } membership.put(levelNames.get(i), Math.max(0.0, Math.min(1.0, degree))); diff --git a/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/GradeRange.java b/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/GradeRange.java index 5ec7ce9..8809f29 100644 --- a/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/GradeRange.java +++ b/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/GradeRange.java @@ -1,5 +1,7 @@ package com.hshh.system.algorithm.fuzzy; +import lombok.Data; + /** * [类的简要说明] *

@@ -9,21 +11,18 @@ package com.hshh.system.algorithm.fuzzy; * @author LiDongYU * @since 2025/7/22 */ +@Data public class GradeRange { private String gradeName; private double lowerBound; private double upperBound; - - public GradeRange(String gradeName, double lowerBound, double upperBound) { + private String equalVal; + public GradeRange(String gradeName, double lowerBound, double upperBound, String equalVal) { this.gradeName = gradeName; this.lowerBound = lowerBound; this.upperBound = upperBound; + this.equalVal = equalVal; } - public String getGradeName() { return gradeName; } - public double getLowerBound() { return lowerBound; } - public double getUpperBound() { return upperBound; } - public void setGradeName(String gradeName) { this.gradeName = gradeName; } - public void setLowerBound(double lowerBound) { this.lowerBound = lowerBound; } - public void setUpperBound(double upperBound) { this.upperBound = upperBound; } + } diff --git a/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/IndicatorNode.java b/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/IndicatorNode.java index 8d25a76..a61da85 100644 --- a/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/IndicatorNode.java +++ b/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/IndicatorNode.java @@ -21,7 +21,7 @@ public class IndicatorNode { private String id; private String name; private Double weight; - private Double actualValue; + private Object actualValue; private MembershipFunction membershipFunction; private List children; private IndicatorNode parent; @@ -34,11 +34,14 @@ public class IndicatorNode { private String logicName; private int projectId; + + public IndicatorNode(String id, String name) { this.id = id; this.name = name; this.children = new ArrayList<>(); this.membershipDegrees = new HashMap<>(); + } diff --git a/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/LeafFullTriangularMembershipFunction.java b/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/LeafFullTriangularMembershipFunction.java index 439f650..5f436b9 100644 --- a/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/LeafFullTriangularMembershipFunction.java +++ b/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/LeafFullTriangularMembershipFunction.java @@ -14,6 +14,7 @@ import java.util.Map; * @since 2025/7/22 */ public class LeafFullTriangularMembershipFunction implements MembershipFunction { + private List gradeRanges; private double overlapRatio; private double peakRatio; @@ -36,76 +37,63 @@ public class LeafFullTriangularMembershipFunction implements MembershipFunction List globalLevels = globalConfig.getAllLevelNames(); for (GradeRange range : gradeRanges) { if (!globalLevels.contains(range.getGradeName())) { - throw new IllegalArgumentException("评价等级名称 '" + range.getGradeName() + "' 不在全局定义中"); + throw new IllegalArgumentException( + "评价等级名称 '" + range.getGradeName() + "' 不在全局定义中"); } } } @Override - public Map calculateMembership(double value) { - System.out.println("\n🔍 ===== ALL_TRI算法开始计算隶属度 ====="); - System.out.println("输入值: " + value); - System.out.println("重叠比例: " + overlapRatio); - System.out.println("峰值比例: " + peakRatio); - System.out.println("软边界: " + softEdge); - System.out.println("等级数量: " + gradeRanges.size()); - + public Map calculateMembership(Object value) { Map membership = new HashMap<>(); // 初始化所有全局等级的隶属度为0 for (String levelName : globalConfig.getAllLevelNames()) { membership.put(levelName, 0.0); } - - System.out.println("\n📊 开始逐个计算等级隶属度:"); - - for (int i = 0; i < gradeRanges.size(); i++) { - GradeRange range = gradeRanges.get(i); - - System.out.println("\n--- 第" + (i+1) + "个等级: " + range.getGradeName() + " ---"); - System.out.println("原始区间: [" + range.getLowerBound() + ", " + range.getUpperBound() + "]"); - - double degree = calculateTriangle(value, range, i); - degree = Math.max(0.0, Math.min(1.0, degree)); - membership.put(range.getGradeName(), degree); - - System.out.println("最终隶属度: " + degree); - } - - System.out.println("\n📈 归一化前的隶属度:"); - double totalBefore = 0.0; - for (Map.Entry entry : membership.entrySet()) { - System.out.println(" " + entry.getKey() + ": " + String.format("%.6f", entry.getValue())); - totalBefore += entry.getValue(); - } - System.out.println("归一化前总和: " + String.format("%.6f", totalBefore)); - - // 🔥 关键修复:添加归一化处理 - if (totalBefore > 0 && Math.abs(totalBefore - 1.0) > 0.001) { - System.out.println("\n🔄 开始归一化处理:"); - - for (String key : membership.keySet()) { - if (membership.get(key) > 0) { - double originalValue = membership.get(key); - double normalizedValue = originalValue / totalBefore; - membership.put(key, normalizedValue); - System.out.println(" " + key + ": " + String.format("%.6f", originalValue) + " → " + String.format("%.6f", normalizedValue)); + if (!isNumber(value.toString())) { + for (GradeRange range : gradeRanges) { + if (range.getEqualVal().equals(value)) { + if (membership.get(range.getGradeName()) != null) { + membership.put(range.getGradeName(), 1.0); + break; + } } } - - double totalAfter = membership.values().stream().mapToDouble(Double::doubleValue).sum(); - System.out.println("归一化后总和: " + String.format("%.6f", totalAfter)); - } else { - System.out.println("\n✅ 无需归一化 (总和已接近1.0)"); } - System.out.println("\n📋 最终隶属度结果:"); - for (Map.Entry entry : membership.entrySet()) { - if (entry.getValue() > 0) { - System.out.println(" " + entry.getKey() + ": " + String.format("%.6f", entry.getValue())); + if (isNumber(value.toString())) { + for (int i = 0; i < gradeRanges.size(); i++) { + GradeRange range = gradeRanges.get(i); + + double degree = calculateTriangle(Double.parseDouble(value.toString()) , range, i); + degree = Math.max(0.0, Math.min(1.0, degree)); + membership.put(range.getGradeName(), degree); + + + } + + double totalBefore = 0.0; + for (Map.Entry entry : membership.entrySet()) { + + totalBefore += entry.getValue(); + } + + // 🔥 关键修复:添加归一化处理 + if (totalBefore > 0 && Math.abs(totalBefore - 1.0) > 0.001) { + + for (String key : membership.keySet()) { + if (membership.get(key) > 0) { + double originalValue = membership.get(key); + double normalizedValue = originalValue / totalBefore; + membership.put(key, normalizedValue); + + } + } + + } } - System.out.println("===== ALL_TRI算法计算完成 =====\n"); return membership; } @@ -142,37 +130,27 @@ public class LeafFullTriangularMembershipFunction implements MembershipFunction System.out.println(" 最后一个等级,右边界大幅延伸: " + rightBoundary); } - System.out.println(" 区间宽度: " + rangeWidth); - System.out.println(" 重叠距离: " + overlap); - System.out.println(" 扩展后区间: [" + leftBoundary + ", " + rightBoundary + "]"); - double result; if (value <= leftBoundary || value >= rightBoundary) { - System.out.println(" 判断: value 在扩展区间外 → 返回 0.0"); + result = 0.0; } else if (Math.abs(value - peakPoint) < 0.0001) { // 处理浮点数比较 - System.out.println(" 判断: value 等于峰值点 → 返回 1.0"); + result = 1.0; } else if (value <= peakPoint) { // 上升边 double slope = 1.0 / (peakPoint - leftBoundary); double basicDegree = (value - leftBoundary) * slope; - System.out.println(" 判断: 上升边计算"); - System.out.println(" 上升边区间: [" + leftBoundary + ", " + peakPoint + "]"); - System.out.println(" 斜率: " + slope); - System.out.println(" 基础隶属度: " + basicDegree); + result = applySoftEdge(basicDegree); - System.out.println(" 软边界处理后: " + result); + } else { // 下降边 double slope = 1.0 / (rightBoundary - peakPoint); double basicDegree = (rightBoundary - value) * slope; - System.out.println(" 判断: 下降边计算"); - System.out.println(" 下降边区间: [" + peakPoint + ", " + rightBoundary + "]"); - System.out.println(" 斜率: " + slope); - System.out.println(" 基础隶属度: " + basicDegree); + result = applySoftEdge(basicDegree); - System.out.println(" 软边界处理后: " + result); + } return result; @@ -180,11 +158,11 @@ public class LeafFullTriangularMembershipFunction implements MembershipFunction private double applySoftEdge(double degree) { if (softEdge <= 0) { - System.out.println(" 软边界处理: softEdge <= 0,直接返回原值"); + return degree; } else { double result = 1.0 / (1.0 + Math.exp(-softEdge * (degree - 0.5))); - System.out.println(" 软边界处理: sigmoid函数," + degree + " → " + result); + return result; } } diff --git a/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/LeafHybridMembershipFunction.java b/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/LeafHybridMembershipFunction.java index a2f1883..8fd09c3 100644 --- a/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/LeafHybridMembershipFunction.java +++ b/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/LeafHybridMembershipFunction.java @@ -14,6 +14,7 @@ import java.util.Map; * @since 2025/7/22 */ public class LeafHybridMembershipFunction implements MembershipFunction { + private List gradeRanges; private double overlapRatio; private double peakRatio; @@ -36,14 +37,14 @@ public class LeafHybridMembershipFunction implements MembershipFunction { List globalLevels = globalConfig.getAllLevelNames(); for (GradeRange range : gradeRanges) { if (!globalLevels.contains(range.getGradeName())) { - throw new IllegalArgumentException("评价等级名称 '" + range.getGradeName() + "' 不在全局定义中"); + throw new IllegalArgumentException( + "评价等级名称 '" + range.getGradeName() + "' 不在全局定义中"); } } } @Override - public Map calculateMembership(double value) { - + public Map calculateMembership(Object value) { Map membership = new HashMap<>(); @@ -52,68 +53,63 @@ public class LeafHybridMembershipFunction implements MembershipFunction { membership.put(levelName, 0.0); } - System.out.println("\n📊 开始逐个计算等级隶属度:"); - - // 计算每个自定义区间的隶属度 - for (int i = 0; i < gradeRanges.size(); i++) { - GradeRange range = gradeRanges.get(i); - - System.out.println("\n--- 第" + (i+1) + "个等级: " + range.getGradeName() + " ---"); - System.out.println("原始区间: [" + range.getLowerBound() + ", " + range.getUpperBound() + "]"); - - double degree = 0.0; - - if (i == 0) { - System.out.println("类型: 左梯形 (第一个等级)"); - degree = calculateLeftTrapezoid(value, range, i); - } else if (i == gradeRanges.size() - 1) { - System.out.println("类型: 右梯形 (最后一个等级)"); - degree = calculateRightTrapezoid(value, range, i); - } else { - System.out.println("类型: 三角形 (中间等级)"); - degree = calculateTriangle(value, range, i); - } - - degree = Math.max(0.0, Math.min(1.0, degree)); - membership.put(range.getGradeName(), degree); - - System.out.println("最终隶属度: " + degree); - } - - System.out.println("\n📈 归一化前的隶属度:"); - double totalBefore = 0.0; - for (Map.Entry entry : membership.entrySet()) { - System.out.println(" " + entry.getKey() + ": " + String.format("%.6f", entry.getValue())); - totalBefore += entry.getValue(); - } - System.out.println("归一化前总和: " + String.format("%.6f", totalBefore)); - - // 归一化处理(修正版) - if (totalBefore > 0 && Math.abs(totalBefore - 1.0) > 0.001) { - System.out.println("\n🔄 开始归一化处理:"); - - for (String key : membership.keySet()) { - if (membership.get(key) > 0) { - double originalValue = membership.get(key); - double normalizedValue = originalValue / totalBefore; - membership.put(key, normalizedValue); - System.out.println(" " + key + ": " + String.format("%.6f", originalValue) + " → " + String.format("%.6f", normalizedValue)); + if (!isNumber(value.toString())) { + for (GradeRange range : gradeRanges) { + if (range.getEqualVal().equals(value)) { + if (membership.get(range.getGradeName()) != null) { + membership.put(range.getGradeName(), 1.0); + break; + } } } - - double totalAfter = membership.values().stream().mapToDouble(Double::doubleValue).sum(); - System.out.println("归一化后总和: " + String.format("%.6f", totalAfter)); - } else { - System.out.println("\n✅ 无需归一化 (总和已接近1.0)"); } - System.out.println("\n📋 最终隶属度结果:"); - for (Map.Entry entry : membership.entrySet()) { - if (entry.getValue() > 0) { - System.out.println(" " + entry.getKey() + ": " + String.format("%.6f", entry.getValue())); + if (isNumber(value.toString())) { + + // 计算每个自定义区间的隶属度 + for (int i = 0; i < gradeRanges.size(); i++) { + GradeRange range = gradeRanges.get(i); + + double degree = 0.0; + + if (i == 0) { + + degree = calculateLeftTrapezoid(Double.parseDouble(value.toString()), range, i); + } else if (i == gradeRanges.size() - 1) { + + degree = calculateRightTrapezoid(Double.parseDouble(value.toString()), range, i); + } else { + + degree = calculateTriangle(Double.parseDouble(value.toString()), range, i); + } + + degree = Math.max(0.0, Math.min(1.0, degree)); + membership.put(range.getGradeName(), degree); + + + } + + double totalBefore = 0.0; + for (Map.Entry entry : membership.entrySet()) { + + totalBefore += entry.getValue(); + } + + // 归一化处理(修正版) + if (totalBefore > 0 && Math.abs(totalBefore - 1.0) > 0.001) { + + for (String key : membership.keySet()) { + if (membership.get(key) > 0) { + double originalValue = membership.get(key); + double normalizedValue = originalValue / totalBefore; + membership.put(key, normalizedValue); + + } + } + + } } - System.out.println("===== 隶属度计算完成 =====\n"); return membership; } @@ -125,27 +121,22 @@ public class LeafHybridMembershipFunction implements MembershipFunction { double nextLowerBound = index + 1 < gradeRanges.size() ? gradeRanges.get(index + 1).getLowerBound() : plateauEnd; - System.out.println(" 平台区间: [" + plateauStart + ", " + plateauEnd + "]"); - System.out.println(" 下一等级下界: " + nextLowerBound); - double result; if (value <= plateauStart) { - System.out.println(" 判断: value <= plateauStart → 返回 1.0"); + result = 1.0; } else if (value <= plateauEnd) { - System.out.println(" 判断: plateauStart < value <= plateauEnd → 返回 1.0"); + result = 1.0; } else if (value >= nextLowerBound) { - System.out.println(" 判断: value >= nextLowerBound → 返回 0.0"); + result = 0.0; } else { double slope = 1.0 / (nextLowerBound - plateauEnd); double basicDegree = (nextLowerBound - value) * slope; - System.out.println(" 判断: 下降边计算"); - System.out.println(" 斜率: " + slope); - System.out.println(" 基础隶属度: " + basicDegree); + result = applySoftEdge(basicDegree); - System.out.println(" 软边界处理后: " + result); + } return result; @@ -160,11 +151,6 @@ public class LeafHybridMembershipFunction implements MembershipFunction { double overlap = rangeWidth * overlapRatio; double leftExtend = plateauStart - overlap; - System.out.println(" 平台区间: [" + plateauStart + ", " + plateauEnd + "]"); - System.out.println(" 区间宽度: " + rangeWidth); - System.out.println(" 重叠距离: " + overlap); - System.out.println(" 左扩展点: " + leftExtend); - double result; if (value <= leftExtend) { System.out.println(" 判断: value <= leftExtend → 返回 0.0"); @@ -172,13 +158,11 @@ public class LeafHybridMembershipFunction implements MembershipFunction { } else if (value <= plateauStart) { double slope = 1.0 / (plateauStart - leftExtend); double basicDegree = (value - leftExtend) * slope; - System.out.println(" 判断: 上升边计算"); - System.out.println(" 斜率: " + slope); - System.out.println(" 基础隶属度: " + basicDegree); + result = applySoftEdge(basicDegree); - System.out.println(" 软边界处理后: " + result); + } else { - System.out.println(" 判断: value > plateauStart → 返回 1.0"); + result = 1.0; } @@ -196,36 +180,25 @@ public class LeafHybridMembershipFunction implements MembershipFunction { double leftBoundary = lowerBound - overlap / 2; double rightBoundary = upperBound + overlap / 2; - System.out.println(" 区间宽度: " + rangeWidth); - System.out.println(" 重叠距离: " + overlap); - System.out.println(" 峰值点: " + peakPoint); - System.out.println(" 扩展后区间: [" + leftBoundary + ", " + rightBoundary + "]"); - double result; if (value <= leftBoundary || value >= rightBoundary) { - System.out.println(" 判断: value 在扩展区间外 → 返回 0.0"); + result = 0.0; } else if (Math.abs(value - peakPoint) < 0.0001) { // 处理浮点数比较 - System.out.println(" 判断: value 等于峰值点 → 返回 1.0"); + result = 1.0; } else if (value < peakPoint) { double slope = 1.0 / (peakPoint - leftBoundary); double basicDegree = (value - leftBoundary) * slope; - System.out.println(" 判断: 上升边计算"); - System.out.println(" 上升边区间: [" + leftBoundary + ", " + peakPoint + "]"); - System.out.println(" 斜率: " + slope); - System.out.println(" 基础隶属度: " + basicDegree); + result = applySoftEdge(basicDegree); - System.out.println(" 软边界处理后: " + result); + } else { double slope = 1.0 / (rightBoundary - peakPoint); double basicDegree = (rightBoundary - value) * slope; - System.out.println(" 判断: 下降边计算"); - System.out.println(" 下降边区间: [" + peakPoint + ", " + rightBoundary + "]"); - System.out.println(" 斜率: " + slope); - System.out.println(" 基础隶属度: " + basicDegree); + result = applySoftEdge(basicDegree); - System.out.println(" 软边界处理后: " + result); + } return result; @@ -233,11 +206,11 @@ public class LeafHybridMembershipFunction implements MembershipFunction { private double applySoftEdge(double degree) { if (softEdge <= 0) { - System.out.println(" 软边界处理: softEdge <= 0,直接返回原值"); + return degree; } else { double result = 1.0 / (1.0 + Math.exp(-softEdge * (degree - 0.5))); - System.out.println(" 软边界处理: sigmoid函数," + degree + " → " + result); + return result; } } diff --git a/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/MembershipFunction.java b/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/MembershipFunction.java index 411876e..237f6fe 100644 --- a/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/MembershipFunction.java +++ b/manager-system/src/main/java/com/hshh/system/algorithm/fuzzy/MembershipFunction.java @@ -12,6 +12,12 @@ import java.util.Map; * @since 2025/7/22 */ public interface MembershipFunction { - Map calculateMembership(double value); + + Map calculateMembership(Object value); + String getType(); + + default boolean isNumber(String str) { + return str != null && str.matches("^\\d+(\\.\\d+)?$"); + } } diff --git a/manager-system/src/main/java/com/hshh/system/aspect/LogOperationAspect.java b/manager-system/src/main/java/com/hshh/system/aspect/LogOperationAspect.java index f1d957d..1ad3da0 100644 --- a/manager-system/src/main/java/com/hshh/system/aspect/LogOperationAspect.java +++ b/manager-system/src/main/java/com/hshh/system/aspect/LogOperationAspect.java @@ -3,6 +3,7 @@ package com.hshh.system.aspect; import com.hshh.system.Global; import com.hshh.system.annotation.LogOperation; import com.hshh.system.base.entity.Logs; +import com.hshh.system.common.Strings.StringUtil; import com.hshh.system.common.jwt.JwtUtil; import com.hshh.system.common.util.IpUtil; import java.time.LocalDateTime; @@ -37,23 +38,48 @@ public class LogOperationAspect { public void logPointcut() { } - @SuppressWarnings("checkstyle:VariableDeclarationUsageDistance") + @Before("logPointcut()") public void before(JoinPoint joinPoint) { + try { + HttpServletRequest request = getCurrentRequest(); + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + LogOperation logOperation = signature.getMethod().getAnnotation(LogOperation.class); + Object[] args = joinPoint.getArgs(); + String ip = getCurrentUserIp(); + String userName = JwtUtil.getCurrentUsername(); + Logs logs = new Logs(); + logs.setIp(ip); + logs.setOperator(userName); + logs.setType("BIZ"); + if (request != null) { + logs.setUrl(request.getRequestURL().toString()); + logs.setParams(StringUtil.getParamsAsJson(request)); + } - MethodSignature signature = (MethodSignature) joinPoint.getSignature(); - LogOperation logOperation = signature.getMethod().getAnnotation(LogOperation.class); - String ip = getCurrentUserIp(); - String userName = JwtUtil.getCurrentUsername(); - Logs logs = new Logs(); - logs.setIp(ip); - logs.setOperator(userName); - logs.setType("BIZ"); - logs.setCreateTime(LocalDateTime.now()); - if (logOperation != null) { - logs.setMsg(logOperation.value()); + logs.setCreateTime(LocalDateTime.now()); + if (logOperation != null) { + logs.setMsg(logOperation.value()); + } + Global.logQueue.offer(logs); + } catch (Exception e) { + log.error(e.getMessage()); + } + + } + + /** + * 获取当前请求的HttpServletRequest. + */ + private HttpServletRequest getCurrentRequest() { + try { + ServletRequestAttributes attributes = + (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes(); + return attributes.getRequest(); + } catch (IllegalStateException e) { + log.warn("无法获取当前请求上下文"); + return null; } - Global.logQueue.offer(logs); } /** diff --git a/manager-system/src/main/java/com/hshh/system/auth/controller/LoginController.java b/manager-system/src/main/java/com/hshh/system/auth/controller/LoginController.java index 40d9a93..fad36bc 100644 --- a/manager-system/src/main/java/com/hshh/system/auth/controller/LoginController.java +++ b/manager-system/src/main/java/com/hshh/system/auth/controller/LoginController.java @@ -169,6 +169,8 @@ public class LoginController { if (extendUserDetails.isAdmin()) { request.setAttribute("menus", menusService.getRootMenus()); + } else { + request.setAttribute("menus", menusService.getUserMenus(extendUserDetails.getId())); } return "home"; } diff --git a/manager-system/src/main/java/com/hshh/system/auth/controller/ThirdLoginController.java b/manager-system/src/main/java/com/hshh/system/auth/controller/ThirdLoginController.java new file mode 100644 index 0000000..75aa6ce --- /dev/null +++ b/manager-system/src/main/java/com/hshh/system/auth/controller/ThirdLoginController.java @@ -0,0 +1,104 @@ +package com.hshh.system.auth.controller; + +import com.hshh.system.auth.bean.ExtendUserDetails; +import com.hshh.system.base.entity.Users; +import com.hshh.system.base.service.ConfigSetService; +import com.hshh.system.base.service.MenusService; +import com.hshh.system.base.service.UsersService; +import javax.servlet.http.HttpServletRequest; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.web.context.HttpSessionSecurityContextRepository; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * [类的简要说明] + *

+ * [详细描述,可选] + *

+ * + * @author LiDongYU + * @since 2025/7/22 + */ +@Controller +@RequestMapping("/thirdLogin") +@Slf4j +public class ThirdLoginController { + + + private final AuthenticationManager authenticationManager; + + //系统配置参数服务类 + private final ConfigSetService configSetService; + private final MenusService menusService; + private final UsersService usersService; + //第三方页面登录时统一分配简单密码,用于访问功能 + private static final String defaultPassword = "123456"; + + public ThirdLoginController(AuthenticationManager authenticationManager, + + ConfigSetService configSetService, MenusService menusService, UsersService usersService) { + this.authenticationManager = authenticationManager; + + this.configSetService = configSetService; + this.menusService = menusService; + this.usersService = usersService; + + } + + /** + * 外部调用直接进入评估系统页面. + * + * @param username 用户名 + * @param model 容器 + * @param request 请求 + * @return home.html + */ + @GetMapping("/thirdLoginPage") + public String thirdLoginPage(String username, Model model, + HttpServletRequest request) { + try { + Users exitUser = usersService.getUserByUsername(username); + if (exitUser == null) { + //建立新用户 + Users user = new Users(); + user.setUsername(username); + user.setNickName(username); + user.setAdmin(true); + user.setHashedPassword(new BCryptPasswordEncoder().encode(defaultPassword)); + usersService.saveUsers(user); + } + //查询用户名是否存在,如果存在,直接登录;如果不存在,新建用户 + UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken( + username, defaultPassword); + //验证 + Authentication authentication = authenticationManager.authenticate(token); + //结果放入 + SecurityContextHolder.getContext().setAuthentication(authentication); + //放入session中 + request.getSession() + .setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, + SecurityContextHolder.getContext()); + ExtendUserDetails extendUserDetails = (ExtendUserDetails) authentication.getPrincipal(); + //用户信息 + request.setAttribute("user", extendUserDetails); + //获取菜单 + if (extendUserDetails.isAdmin()) { + request.setAttribute("menus", menusService.getRootMenus()); + + } + model.addAttribute("systemTitle", configSetService.getTitle()); + + } catch (Exception e) { + log.error(e.getMessage()); + } + return "home"; + } +} diff --git a/manager-system/src/main/java/com/hshh/system/base/controller/FaqController.java b/manager-system/src/main/java/com/hshh/system/base/controller/FaqController.java new file mode 100644 index 0000000..ccc6a79 --- /dev/null +++ b/manager-system/src/main/java/com/hshh/system/base/controller/FaqController.java @@ -0,0 +1,22 @@ +package com.hshh.system.base.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +/** + * [类的简要说明] + *

+ * [详细描述,可选] + *

+ * + * @author LiDongYU + * @since 2025/7/22 + */ +@Controller +public class FaqController { + + @GetMapping("faq") + public String faq() { + return "faq"; + } +} diff --git a/manager-system/src/main/java/com/hshh/system/base/controller/UserController.java b/manager-system/src/main/java/com/hshh/system/base/controller/UserController.java index 13bacb0..89f9f2d 100644 --- a/manager-system/src/main/java/com/hshh/system/base/controller/UserController.java +++ b/manager-system/src/main/java/com/hshh/system/base/controller/UserController.java @@ -13,11 +13,11 @@ import com.hshh.system.common.bean.BaseController; import com.hshh.system.common.bean.ErrorField; import com.hshh.system.common.bean.OperateResult; import com.hshh.system.common.bean.PaginationBean; -import com.hshh.system.common.bean.TableRowsResult; import com.hshh.system.common.enums.ErrorCode; import com.hshh.system.common.enums.ErrorMessage; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.Collections; import java.util.List; import javax.annotation.Resource; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; @@ -125,9 +125,10 @@ public class UserController extends BaseController { private OperateResult handleUserSave(Users user) { //检查确认密码和密码是否一致 - if (!user.getHashedPassword().equalsIgnoreCase(user.getConfirmHashedPassword())) { + if (user.getHashedPassword() != null && user.getConfirmHashedPassword() != null + && !user.getHashedPassword().equalsIgnoreCase(user.getConfirmHashedPassword())) { ErrorField errorField = new ErrorField("confirmHashedPassword", "确认密码和密码不一致"); - List errorFieldList = List.of(errorField); + List errorFieldList = Collections.singletonList(errorField); return OperateResult.error(null, "", ErrorCode.PARAM_FORMAT.getCode(), errorFieldList); } if (user.getHashedPassword() != null && !user.getHashedPassword().equalsIgnoreCase("")) { diff --git a/manager-system/src/main/java/com/hshh/system/base/entity/Users.java b/manager-system/src/main/java/com/hshh/system/base/entity/Users.java index 6da1f72..be3ffd1 100644 --- a/manager-system/src/main/java/com/hshh/system/base/entity/Users.java +++ b/manager-system/src/main/java/com/hshh/system/base/entity/Users.java @@ -31,8 +31,8 @@ public class Users extends BaseBean { private String username; @NotBlank(message = "密码不能为空", groups = {CreateUser.class}) @Pattern( - regexp = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[\\W_]).{6,}$", - message = "密码不少于6位,且至少包含大写字母、小写字母、数字和特殊符号", + regexp = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).{6,}$", + message = "密码不少于6位,且至少包含大写字母、小写字母、数字", groups = {CreateUser.class, UpdateUser.class} ) @@ -42,8 +42,8 @@ public class Users extends BaseBean { @Setter @NotBlank(message = "确认密码不能为空", groups = {CreateUser.class}) @Pattern( - regexp = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[\\W_]).{6,}$", - message = "确认密码密码不少于6位,且至少包含大写字母、小写字母、数字和特殊符号", + regexp = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).{6,}$", + message = "确认密码密码不少于6位,且至少包含大写字母、小写字母、数字", groups = {CreateUser.class, UpdateUser.class} ) private String confirmHashedPassword; @@ -90,6 +90,7 @@ public class Users extends BaseBean { /** * 昵称. */ + @NotBlank(message = "昵称不能为空") @Size(max = 50, message = "昵称不能超过50字符") private String nickName; diff --git a/manager-system/src/main/java/com/hshh/system/base/service/TableRelationsService.java b/manager-system/src/main/java/com/hshh/system/base/service/TableRelationsService.java index f491193..bdb651f 100644 --- a/manager-system/src/main/java/com/hshh/system/base/service/TableRelationsService.java +++ b/manager-system/src/main/java/com/hshh/system/base/service/TableRelationsService.java @@ -10,6 +10,7 @@ import java.util.List; * @author liDongYu * @since 2025-07-29 */ +@Deprecated public interface TableRelationsService extends IService { /** @@ -19,6 +20,7 @@ public interface TableRelationsService extends IService { * @param dstTable 引用表 * @return 查询结果 */ + @Deprecated List queryRel(Integer id, String dstTable); /** @@ -28,6 +30,7 @@ public interface TableRelationsService extends IService { * @param srcTable 原表名称 * @param dstTable 目标表名称 */ + @Deprecated void removeRel(Integer srcId, String srcTable, String dstTable); /** @@ -38,6 +41,7 @@ public interface TableRelationsService extends IService { * @param dstId 目标表ID * @param dstTable 目标表名称 */ + @Deprecated void removeRel(Integer srcId, String srcTable, Integer dstId, String dstTable); /** @@ -48,6 +52,7 @@ public interface TableRelationsService extends IService { * @param dstIdList 引用表ID集合 * @param dstTable 引用表 */ + @Deprecated void addRel(Integer srcId, String srcTable, List dstIdList, String dstTable); } diff --git a/manager-system/src/main/java/com/hshh/system/common/enums/ErrorMessage.java b/manager-system/src/main/java/com/hshh/system/common/enums/ErrorMessage.java index 43bb545..2c6b0af 100644 --- a/manager-system/src/main/java/com/hshh/system/common/enums/ErrorMessage.java +++ b/manager-system/src/main/java/com/hshh/system/common/enums/ErrorMessage.java @@ -11,7 +11,7 @@ import lombok.Getter; @Getter public enum ErrorMessage { NAME_OR_CODE_EXIT("名称或者编码已经存在"), - + NAME_EXIT("名称或者编码已经存在"), ID_NOT_EXIT("记录不存在"), SUCCESS("操作成功"), diff --git a/manager-system/src/main/java/com/hshh/system/common/util/FileUtil.java b/manager-system/src/main/java/com/hshh/system/common/util/FileUtil.java new file mode 100644 index 0000000..c9907f6 --- /dev/null +++ b/manager-system/src/main/java/com/hshh/system/common/util/FileUtil.java @@ -0,0 +1,68 @@ +package com.hshh.system.common.util; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import org.springframework.web.multipart.MultipartFile; + +/** + * [类的简要说明] + *

+ * [详细描述,可选] + *

+ * + * @author LiDongYU + * @since 2025/7/22 + */ +public class FileUtil { + + // 从InputStream解析CSV + public static List> parseCsvFromInputStream(MultipartFile file) throws IOException { + List> result = new ArrayList<>(); + + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(file.getInputStream(), StandardCharsets.UTF_8))) { + String line; + while ((line = reader.readLine()) != null) { + if (!line.trim().isEmpty()) { + result.add(parseCsvLine(line)); + } + } + } + + return result; + } + + // 解析单行CSV + private static List parseCsvLine(String line) { + List fields = new ArrayList<>(); + StringBuilder currentField = new StringBuilder(); + boolean inQuotes = false; + + for (int i = 0; i < line.length(); i++) { + char currentChar = line.charAt(i); + char nextChar = (i + 1 < line.length()) ? line.charAt(i + 1) : '\0'; + + if (currentChar == '"') { + if (inQuotes && nextChar == '"') { + currentField.append('"'); + i++; + } else { + inQuotes = !inQuotes; + } + } else if (currentChar == ',' && !inQuotes) { + fields.add(currentField.toString()); + currentField.setLength(0); + } else { + currentField.append(currentChar); + } + } + + fields.add(currentField.toString()); + return fields; + } +} diff --git a/manager-system/src/main/java/com/hshh/system/common/util/StringTool.java b/manager-system/src/main/java/com/hshh/system/common/util/StringTool.java new file mode 100644 index 0000000..d4d703a --- /dev/null +++ b/manager-system/src/main/java/com/hshh/system/common/util/StringTool.java @@ -0,0 +1,90 @@ +package com.hshh.system.common.util; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * [类的简要说明] + *

+ * [详细描述,可选] + *

+ * + * @author LiDongYU + * @since 2025/7/22 + */ +public class StringTool { + + public static Set checkDuplicates(String content, String split) { + + // 按 , ; 换行 分割 + String[] childTextArray = content.split(split); + + // 用于去重和判断重复 + Set set = new HashSet<>(); + Set duplicates = new HashSet<>(); + + for (String name : childTextArray) { + name = name.trim(); + if (name.isEmpty()) { + continue; + } + if (!set.add(name)) { + duplicates.add(name); + } + } + + return duplicates; + } + + public static List> parseCSV(String csvText) { + List> rows = new ArrayList<>(); + List currentRow = new ArrayList<>(); + StringBuilder currentField = new StringBuilder(); + boolean inQuotes = false; + + for (int i = 0; i < csvText.length(); i++) { + char currentChar = csvText.charAt(i); + char nextChar = (i + 1 < csvText.length()) ? csvText.charAt(i + 1) : '\0'; + + if (currentChar == '"') { + if (inQuotes && nextChar == '"') { + // 处理双引号转义 + currentField.append('"'); + i++; // 跳过下一个引号 + } else { + // 切换引号状态 + inQuotes = !inQuotes; + } + } else if (currentChar == ',' && !inQuotes) { + // 字段分隔符 + currentRow.add(currentField.toString()); + currentField.setLength(0); + } else if ((currentChar == '\n' || currentChar == '\r') && !inQuotes) { + // 行结束 + if (currentField.length() > 0 || !currentRow.isEmpty()) { + currentRow.add(currentField.toString()); + rows.add(new ArrayList<>(currentRow)); + currentRow.clear(); + currentField.setLength(0); + } + // 跳过 \r\n 中的 \n + if (currentChar == '\r' && nextChar == '\n') { + i++; + } + } else { + // 普通字符 + currentField.append(currentChar); + } + } + + // 处理最后一行 + if (currentField.length() > 0 || !currentRow.isEmpty()) { + currentRow.add(currentField.toString()); + rows.add(currentRow); + } + + return rows; + } +} diff --git a/manager-system/src/main/java/com/hshh/system/config/SecurityConfig.java b/manager-system/src/main/java/com/hshh/system/config/SecurityConfig.java index f6f3373..20013a0 100644 --- a/manager-system/src/main/java/com/hshh/system/config/SecurityConfig.java +++ b/manager-system/src/main/java/com/hshh/system/config/SecurityConfig.java @@ -19,7 +19,7 @@ import org.springframework.security.crypto.password.PasswordEncoder; @Configuration public class SecurityConfig extends WebSecurityConfigurerAdapter { - @Resource (name="userAuthService") + @Resource(name = "userAuthService") private UserDetailsService userAuthService; @Bean @@ -34,9 +34,11 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { - http + //允许iframe + http.headers().frameOptions().disable().and() .authorizeRequests() .antMatchers("/login", "/css/**", "/js/**", "/img/**", "/libs/**", "/captcha", "/toAuth", + "/thirdLogin/**", "/ws/**", "/swagger-ui.html", "/swagger-ui/**", "/webfonts/**", @@ -77,6 +79,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { } public static void main(String[] args) { - System.out.println( new BCryptPasswordEncoder().encode("123456")); ; + System.out.println(new BCryptPasswordEncoder().encode("123456")); + ; } } diff --git a/manager-system/src/main/java/com/hshh/system/config/EndpointConfig.java b/manager-system/src/main/java/com/hshh/system/config/WsEndpointConfig.java similarity index 92% rename from manager-system/src/main/java/com/hshh/system/config/EndpointConfig.java rename to manager-system/src/main/java/com/hshh/system/config/WsEndpointConfig.java index b80b640..4e65d46 100644 --- a/manager-system/src/main/java/com/hshh/system/config/EndpointConfig.java +++ b/manager-system/src/main/java/com/hshh/system/config/WsEndpointConfig.java @@ -11,7 +11,7 @@ import org.springframework.web.socket.server.standard.ServerEndpointExporter; * @since 2025/7/22 */ @Configuration -public class EndpointConfig { +public class WsEndpointConfig { @Bean public ServerEndpointExporter serverEndpointExporter() { diff --git a/manager-system/src/main/java/com/hshh/system/exception/ApiGlobalExceptionHandler.java b/manager-system/src/main/java/com/hshh/system/exception/ApiGlobalExceptionHandler.java index ad64170..0a76403 100644 --- a/manager-system/src/main/java/com/hshh/system/exception/ApiGlobalExceptionHandler.java +++ b/manager-system/src/main/java/com/hshh/system/exception/ApiGlobalExceptionHandler.java @@ -1,5 +1,6 @@ package com.hshh.system.exception; +import com.hshh.system.Global; import com.hshh.system.base.entity.Logs; import com.hshh.system.common.Strings.StringUtil; import com.hshh.system.common.bean.OperateResult; @@ -33,7 +34,7 @@ public class ApiGlobalExceptionHandler { */ @ExceptionHandler(Exception.class) public OperateResult handleAll(Exception ex, HttpServletRequest req) { - + log.error("error happened", ex); recordLog(ex, req); String msg = ex.getMessage(); return OperateResult.error(null, msg, ErrorCode.BUSINESS_ERROR.getCode()); @@ -42,7 +43,7 @@ public class ApiGlobalExceptionHandler { private void recordLog(Exception ex, HttpServletRequest req) { try { Logs logs = new Logs(); - logs.setMsg(ex.getMessage()); + logs.setMsg(ex.getLocalizedMessage()); logs.setType("ERROR"); //来源IP logs.setIp(IpUtil.getClientIpAddress(req)); @@ -58,6 +59,7 @@ public class ApiGlobalExceptionHandler { logs.setHttpMethod(req.getMethod()); //请求的参数 logs.setParams(StringUtil.getParamsAsJson(req)); + Global.logQueue.add(logs); log.error("error::", ex); } catch (Exception e) { log.error("error::", e); diff --git a/manager-system/src/main/java/com/hshh/system/filter/MultiReadRequestFilter.java b/manager-system/src/main/java/com/hshh/system/filter/MultiReadRequestFilter.java index 05ae88e..a2970ef 100644 --- a/manager-system/src/main/java/com/hshh/system/filter/MultiReadRequestFilter.java +++ b/manager-system/src/main/java/com/hshh/system/filter/MultiReadRequestFilter.java @@ -32,13 +32,16 @@ public class MultiReadRequestFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { - // 只包装HttpServletRequest if (request instanceof HttpServletRequest) { HttpServletRequest httpRequest = (HttpServletRequest) request; - // 用包装类包装原始request - MultiReadHttpServletRequest multiReadRequest = new MultiReadHttpServletRequest(httpRequest); - // 传递包装后的request - chain.doFilter(multiReadRequest, response); + String contentType = httpRequest.getContentType(); + // 跳过 multipart/form-data 请求,避免包装 + if (contentType != null && contentType.toLowerCase().startsWith("multipart/")) { + chain.doFilter(request, response); + } else { + MultiReadHttpServletRequest multiReadRequest = new MultiReadHttpServletRequest(httpRequest); + chain.doFilter(multiReadRequest, response); + } } else { chain.doFilter(request, response); } diff --git a/pom.xml b/pom.xml index 8c1932b..78ff88d 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,8 @@ 8.0.33 2.6.13 1.11.0 - 3.1.8 + 2.9.3 + 8 @@ -128,8 +129,26 @@ caffeine ${caffeine.version} + + com + dmjdbc + ${dmjdbc.version} + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 + + 8 + 8 + + + + diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..7bee6fa --- /dev/null +++ b/readme.md @@ -0,0 +1,15 @@ +## 1.登录 +![登录](attachment/Clipboard_2025-09-15-21-58-50.png) +## 2. 主页面 +![](attachment/Clipboard_2025-09-15-21-59-14.png) +## 3. 指标建立页面 +![](attachment/Clipboard_2025-09-15-21-59-44.png) +## 权重设计页面 +![](attachment/Clipboard_2025-09-15-22-00-21.png) +## 评价集 +![](attachment/Clipboard_2025-09-15-22-04-15.png) +## 映射集 +![](attachment/Clipboard_2025-09-15-22-05-54.png) +## 开始评估 +![](attachment/Clipboard_2025-09-15-22-06-29.png) +## diff --git a/todo b/todo new file mode 100644 index 0000000..45a0df3 --- /dev/null +++ b/todo @@ -0,0 +1,3 @@ + +2. 报告导出额问题 +3. csv表头解析问题