Danj0rr 11 ヶ月 前
コミット
f7b1218319
1 ファイル変更22 行追加9 行削除
  1. 22 9
      src/main/java/com/kexun/controller/ModelController.java

+ 22 - 9
src/main/java/com/kexun/controller/ModelController.java

@@ -51,21 +51,24 @@ public class ModelController {
     private CustomizedModelService customizedModelService;
     @Autowired
     private FilterResultService parseResultService;
+    @Autowired
+    private CooperatorProductService CooperatorProductService;
 
     private JsonFile jsonFile = new JsonFile();
 
 
     @GetMapping("getModelNo")
-    public Result getModelNo(){
+    public Result getModelNo() {
         JSONObject resJson = new JSONObject();
-        String model_no=userModelService.getModelNo();
-        if (model_no==null)
-            model_no="0";
+        String model_no = userModelService.getModelNo();
+        if (model_no == null)
+            model_no = "0";
         System.out.println(model_no);
 
         resJson.put("model_no", model_no);
         return Result.success("ok", resJson);
     }
+
     //给模型复核员提供模型复核
     @GetMapping("listUser")
     public Result listUser(SysUser sysUser) {
@@ -112,7 +115,7 @@ public class ModelController {
             Reader reader = new InputStreamReader(new FileInputStream(jsonFile), "utf-8");
             int ch = 0;
             StringBuffer sb = new StringBuffer();
-            while((ch = reader.read()) != -1) {
+            while ((ch = reader.read()) != -1) {
                 sb.append((char) ch);
             }
 
@@ -475,9 +478,9 @@ public class ModelController {
         List<ModelEntity> model_Entity_list = userModelService.getUserModel();
 //        System.out.println(model_Entity_list.get(0).getCreateTime());
 
-        PageInfo pageInfo=new PageInfo(model_Entity_list);
+        PageInfo pageInfo = new PageInfo(model_Entity_list);
 //        System.out.println(pageInfo);
-        resJson.put("modelData",pageInfo);
+        resJson.put("modelData", pageInfo);
 
         return Result.success("ok", resJson);
     }
@@ -503,8 +506,8 @@ public class ModelController {
     }
 
 
-        @PostMapping("changeModelByID")
-        public Result changeModelByID(@RequestBody String json, SysUser sysUser) throws IOException {
+    @PostMapping("changeModelByID")
+    public Result changeModelByID(@RequestBody String json, SysUser sysUser) throws IOException {
         //获取参数
         JSONObject resJson = new JSONObject();
         JSONObject req = JSON.parseObject(json);
@@ -622,6 +625,16 @@ public class ModelController {
     public Result deleteModel(@RequestBody String json, SysUser sysUser) {
         JSONObject req = JSON.parseObject(json);
         long id = Long.parseLong(req.getString("modelid"));
+        List<CooperatorProduct> list = CooperatorProductService.getCooperatorByModel(id);
+        if (!list.isEmpty()) {
+            for (int i = 0; i < list.size(); i++) {
+                System.out.println(list.get(i).getProductStatus());
+                if (list.get(i).getProductStatus().equals("1")) {
+                    return Result.error("模型有产品正在使用,不允许删除!");
+                }
+            }
+        }
+
         String fieldCombine = req.getString("fieldCombine");
 //        if(fieldCombine.equals("暂未指定")){
 //