|
@@ -1,20 +1,25 @@
|
|
package com.css.simulation.resource.server.adapter.controller.scene_library.score_rule;
|
|
package com.css.simulation.resource.server.adapter.controller.scene_library.score_rule;
|
|
|
|
|
|
import api.common.pojo.common.ResponseBodyVO;
|
|
import api.common.pojo.common.ResponseBodyVO;
|
|
|
|
+import api.common.pojo.constants.DictConstants;
|
|
import api.common.pojo.constants.LogConstants;
|
|
import api.common.pojo.constants.LogConstants;
|
|
import api.common.pojo.param.scene.ScoringRulesParam;
|
|
import api.common.pojo.param.scene.ScoringRulesParam;
|
|
|
|
+import api.common.pojo.po.scene.SceneEvaluationRulePO;
|
|
import api.common.pojo.po.scene.ScoringRulesPO;
|
|
import api.common.pojo.po.scene.ScoringRulesPO;
|
|
|
|
+import api.common.pojo.vo.scene.SceneEvaluationRuleVO;
|
|
import api.common.pojo.vo.scene.ScoringRulesVO;
|
|
import api.common.pojo.vo.scene.ScoringRulesVO;
|
|
import api.common.util.ObjectUtil;
|
|
import api.common.util.ObjectUtil;
|
|
import api.common.util.PythonUtil;
|
|
import api.common.util.PythonUtil;
|
|
import api.common.util.StringUtil;
|
|
import api.common.util.StringUtil;
|
|
|
|
+import com.css.simulation.resource.server.app.service.ScoringRulesService;
|
|
import com.css.simulation.resource.server.infra.util.AuthUtil;
|
|
import com.css.simulation.resource.server.infra.util.AuthUtil;
|
|
import com.css.simulation.resource.server.infra.util.PageUtil;
|
|
import com.css.simulation.resource.server.infra.util.PageUtil;
|
|
-import com.css.simulation.resource.server.app.service.ScoringRulesService;
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
@@ -22,6 +27,7 @@ import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
//打分规则
|
|
//打分规则
|
|
|
|
+@Slf4j
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping(value = "/ScoringRules", name = LogConstants.MODULE_SCORING)
|
|
@RequestMapping(value = "/ScoringRules", name = LogConstants.MODULE_SCORING)
|
|
public class ScoreRuleController {
|
|
public class ScoreRuleController {
|
|
@@ -76,13 +82,7 @@ public class ScoreRuleController {
|
|
@PostMapping("/saveScoringRules")
|
|
@PostMapping("/saveScoringRules")
|
|
public ResponseBodyVO<String> saveScoringRules(@RequestBody ScoringRulesPO scoringRulesPO) {
|
|
public ResponseBodyVO<String> saveScoringRules(@RequestBody ScoringRulesPO scoringRulesPO) {
|
|
//1 校验 python 语法错误
|
|
//1 校验 python 语法错误
|
|
- String pylint = PythonUtil.pylint(scoringRulesPO.getRuleDetails(),
|
|
|
|
- PythonUtil.C,
|
|
|
|
- PythonUtil.R,
|
|
|
|
- PythonUtil.W,
|
|
|
|
- PythonUtil.E0401,
|
|
|
|
- PythonUtil.E0601
|
|
|
|
- );
|
|
|
|
|
|
+ String pylint = PythonUtil.pylint(scoringRulesPO.getRuleDetails(), PythonUtil.C, PythonUtil.R, PythonUtil.W, PythonUtil.E0401, PythonUtil.E0601);
|
|
if (!pylint.contains(PythonUtil.PASS)) {
|
|
if (!pylint.contains(PythonUtil.PASS)) {
|
|
return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "代码格式错误,请检查。");
|
|
return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "代码格式错误,请检查。");
|
|
}
|
|
}
|
|
@@ -171,4 +171,90 @@ public class ScoreRuleController {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ @RequestMapping(value = "/uploadPyScript")
|
|
|
|
+ public ResponseBodyVO<Map<String, String>> uploadPyScript(@RequestPart("file") MultipartFile file) {
|
|
|
|
+ String roleCode = AuthUtil.getCurrentUserRoleCode();
|
|
|
|
+ if (!DictConstants.ROLE_CODE_ADMIN.equals(roleCode) && !DictConstants.ROLE_CODE_SYSADMIN.equals(roleCode)) {
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "非管理员禁止上传文件");
|
|
|
|
+ }
|
|
|
|
+ return scoringRulesService.uploadPyScript(file);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新增场景评价规则
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/saveSceneEvaluationRule")
|
|
|
|
+ public ResponseBodyVO<String> saveSceneEvaluationRule(@RequestBody SceneEvaluationRulePO sceneEvaluationRulePO) {
|
|
|
|
+ // 判断 ruleId 是否为空
|
|
|
|
+ if (StringUtil.isEmpty(sceneEvaluationRulePO.getRuleId())) {
|
|
|
|
+ // 检查私有是否存在同名平分规则
|
|
|
|
+ SceneEvaluationRulePO serPO = scoringRulesService.querySceneEvaluationRuleOnly(sceneEvaluationRulePO.getRuleName(), AuthUtil.getCurrentUserId());
|
|
|
|
+ if (ObjectUtil.isNotNull(serPO)) {
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "场景规则 " + serPO.getRuleName() + " 已存在,请重新命名。");
|
|
|
|
+ }
|
|
|
|
+ // 创建
|
|
|
|
+ // todo 校验文件是否存在
|
|
|
|
+// if () {
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
+// scoringRulesService.saveSceneEvaluationRule(sceneEvaluationRulePO);
|
|
|
|
+ } else {
|
|
|
|
+ // 修改
|
|
|
|
+// scoringRulesService.updateSceneEvaluationRule(sceneEvaluationRulePO);
|
|
|
|
+ }
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询场景评分规则列表
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/querySceneEvaluationRule")
|
|
|
|
+ public ResponseBodyVO<PageInfo<SceneEvaluationRuleVO>> querySceneEvaluationRule(@RequestBody ScoringRulesParam params) {
|
|
|
|
+ PageUtil.setPageInfo(params);
|
|
|
|
+// List<ScoringRulesPO> list = scoringRulesService.querySceneEvaluationRule(params);
|
|
|
|
+ List<SceneEvaluationRulePO> list = new ArrayList<>();
|
|
|
|
+ PageInfo<SceneEvaluationRulePO> sceneEvaluationRulePOPageInfo = new PageInfo<>(list);
|
|
|
|
+ List<SceneEvaluationRuleVO> list1 = new ArrayList<>();
|
|
|
|
+ //po转vo
|
|
|
|
+ for (SceneEvaluationRulePO po : list) {
|
|
|
|
+ SceneEvaluationRuleVO vo = new SceneEvaluationRuleVO();
|
|
|
|
+ BeanUtils.copyProperties(po, vo);
|
|
|
|
+ list1.add(vo);
|
|
|
|
+ }
|
|
|
|
+ PageInfo<SceneEvaluationRuleVO> pageInfo = new PageInfo<>(list1);
|
|
|
|
+ pageInfo.setTotal(sceneEvaluationRulePOPageInfo.getTotal());
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, pageInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询复杂度脚本
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/querySceneComplexityScript")
|
|
|
|
+ public ResponseBodyVO<List<SceneEvaluationRuleVO>> querySceneComplexityScript(@RequestBody ScoringRulesParam params) {
|
|
|
|
+// List<ScoringRulesPO> list = scoringRulesService.querySceneEvaluationRule(params);
|
|
|
|
+ List<SceneEvaluationRulePO> list = new ArrayList<>();
|
|
|
|
+ List<SceneEvaluationRuleVO> list1 = new ArrayList<>();
|
|
|
|
+ //po转vo
|
|
|
|
+ for (SceneEvaluationRulePO po : list) {
|
|
|
|
+ SceneEvaluationRuleVO vo = new SceneEvaluationRuleVO();
|
|
|
|
+ BeanUtils.copyProperties(po, vo);
|
|
|
|
+ list1.add(vo);
|
|
|
|
+ }
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, list1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除场景评分规则
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/deleteSceneEvaluationRule")
|
|
|
|
+ public ResponseBodyVO<String> deleteSceneEvaluationRule(@RequestBody SceneEvaluationRulePO params) {
|
|
|
|
+ String roleCode = AuthUtil.getCurrentUserRoleCode();
|
|
|
|
+ if (!DictConstants.ROLE_CODE_ADMIN.equals(roleCode) && !DictConstants.ROLE_CODE_SYSADMIN.equals(roleCode)) {
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "非管理员禁止删除");
|
|
|
|
+ }
|
|
|
|
+// scoringRulesService.deleteSceneEvaluationRule(params);
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|