瀏覽代碼

重构模型命名

lgs 1 年之前
父節點
當前提交
89fa729121

+ 6 - 7
src/main/java/com/kexun/common/User.java

@@ -1,7 +1,6 @@
 package com.kexun.common;
+import com.kexun.entity.ModelEntity;
 import com.kexun.entity.UserField;
-import com.kexun.entity.UserModel;
-import com.kexun.service.SysUserService;
 import com.kexun.service.UserApprovalService;
 import com.kexun.service.UserFieldService;
 import com.kexun.service.UserModelService;
@@ -53,11 +52,11 @@ public class User {
     public void initUser(String name)
     {
         user_name=name;
-        List<UserModel> model_list=userModelServices.findByUserName(user_name);
-        if(model_list!=null) {
-            for (int i = 0; i < model_list.size(); i++) {
-                model_name.add(model_list.get(i).getModelName());
-                model_state.add(model_list.get(i).getStatus());
+        List<ModelEntity> model_Entity_list =userModelServices.findByUserName(user_name);
+        if(model_Entity_list !=null) {
+            for (int i = 0; i < model_Entity_list.size(); i++) {
+                model_name.add(model_Entity_list.get(i).getModelName());
+                model_state.add(model_Entity_list.get(i).getStatus());
             }
         }
         UserField userField=userFieldServices.findByUserName(user_name);

+ 29 - 30
src/main/java/com/kexun/controller/FileUploadController.java

@@ -1,16 +1,15 @@
 package com.kexun.controller;
+
+import com.kexun.entity.ModelEntity;
 import org.apache.commons.io.FileUtils;
 
 //import ch.qos.logback.core.rolling.helper.FileStoreUtil;
 //import ch.qos.logback.core.util.FileUtil;
 
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
 import com.kexun.common.FileUploadUtil;
 import com.kexun.common.utils.Result;
 import com.kexun.entity.SysUser;
 import com.kexun.entity.UserApproval;
-import com.kexun.entity.UserModel;
 import com.kexun.service.UserApprovalService;
 import com.kexun.service.UserModelService;
 import lombok.extern.java.Log;
@@ -60,13 +59,13 @@ public class FileUploadController {
         String filename = name.split("\\.")[0];
         String filefmt = name.split("\\.")[1];
         String fullFileName = String.join("-", new String[]{filename, uid, index + "", "." + filefmt});
-        String filePath=fileuploadPath + "/" + sysUser.getUserName() + "/" +filename+"."+filefmt;
+        String filePath = fileuploadPath + "/" + sysUser.getUserName() + "/" + filename + "." + filefmt;
         log.info("filename:" + fullFileName);
         File dir = new File(fileuploadPath + "/" + sysUser.getUserName() + "/");
 
-        if (!dir.exists())
+        if (!dir.exists()) {
             dir.mkdirs();
-
+        }
         File file = new File(fileuploadPath + "/" + sysUser.getUserName() + "/" + fullFileName);
         FileCopyUtils.copy(chunk.getInputStream(), new FileOutputStream(file));
         FileUploadUtil.put(uid, index, chunksLength, fullFileName, fileuploadPath + "/" + sysUser.getUserName() + "/");
@@ -82,8 +81,8 @@ public class FileUploadController {
             throw new RuntimeException(ex.getMessage());
         }
 
-        UserModel model=userModelService.findByID(id);
-        String oldFilePath=model.getFilePath();
+        ModelEntity modelEntity = userModelService.findByID(id);
+        String oldFilePath = modelEntity.getFilePath();
         File oldFile = new File(oldFilePath);
 
         if (oldFile.exists()) {
@@ -93,13 +92,12 @@ public class FileUploadController {
             } catch (IOException e) {
                 System.out.println("file delete fail: " + e.getMessage());
             }
-        }
-        else {
+        } else {
             System.out.println("file not exist");
         }
 
-        model.setFilePath(filePath);
-        userModelService.updateById(model);
+        modelEntity.setFilePath(filePath);
+        userModelService.updateById(modelEntity);
 
 
         return Result.success();
@@ -116,13 +114,13 @@ public class FileUploadController {
             String filename = name.split("\\.")[0];
             String filefmt = name.split("\\.")[1];
             String fullFileName = String.join("-", new String[]{filename, uid, index + "", "." + filefmt});
-            String filePath=fileuploadPath + "/" + sysUser.getUserName() + "/" +filename+"."+filefmt;
+            String filePath = fileuploadPath + "/" + sysUser.getUserName() + "/" + filename + "." + filefmt;
             log.info("filename:" + fullFileName);
             File dir = new File(fileuploadPath + "/" + sysUser.getUserName() + "/");
 
-            if (!dir.exists())
+            if (!dir.exists()) {
                 dir.mkdirs();
-
+            }
             File file = new File(fileuploadPath + "/" + sysUser.getUserName() + "/" + fullFileName);
             FileCopyUtils.copy(chunk.getInputStream(), new FileOutputStream(file));
             FileUploadUtil.put(uid, index, chunksLength, fullFileName, fileuploadPath + "/" + sysUser.getUserName() + "/");
@@ -148,15 +146,15 @@ public class FileUploadController {
 
             //model 数据库连接接口
             String userName = sysUser.getUserName();
-            UserModel new_model = new UserModel();
-            new_model.setCreateBy(userName);
-            new_model.setModelName(model_name);
-            new_model.setModelType(type);
-            new_model.setStatus("暂停使用");
+            ModelEntity new_modelEntity = new ModelEntity();
+            new_modelEntity.setCreateBy(sysUser.getId());
+            new_modelEntity.setModelName(model_name);
+            new_modelEntity.setModelType(type);
+            new_modelEntity.setStatus("暂停使用");
 //            new_model.setOtherData(name);
 //            new_model.setOutputList(output_list);
-            new_model.setFilePath(filePath);
-            userModelService.save(new_model);
+            new_modelEntity.setFilePath(filePath);
+            userModelService.save(new_modelEntity);
 
         } else {
             // http请求
@@ -165,8 +163,9 @@ public class FileUploadController {
             String fullFileName = String.join("-", new String[]{filename, uid, index + "", "." + filefmt});
             log.info("filename:" + fullFileName);
             File dir = new File(warPath);
-            if (!dir.exists())
+            if (!dir.exists()) {
                 dir.mkdirs();
+            }
             File file = new File(warPath + "/" + fullFileName);
             FileCopyUtils.copy(chunk.getInputStream(), new FileOutputStream(file));
             FileUploadUtil.put(uid, index, chunksLength, fullFileName, warPath);
@@ -196,15 +195,15 @@ public class FileUploadController {
 
 
             String userName = sysUser.getUserName();
-            UserModel new_model = new UserModel();
-            new_model.setCreateBy(userName);
-            new_model.setModelName(model_name);
-            new_model.setModelType(type);
-            new_model.setStatus("暂停使用");
+            ModelEntity new_modelEntity = new ModelEntity();
+            new_modelEntity.setCreateBy(sysUser.getId());
+            new_modelEntity.setModelName(model_name);
+            new_modelEntity.setModelType(type);
+            new_modelEntity.setStatus("暂停使用");
 //                new_model.setOtherData(name);
 //                new_model.setOutputList(output_list);
-            new_model.setFilePath(warPath + "/" + fullFileName);
-            userModelService.save(new_model);
+            new_modelEntity.setFilePath(warPath + "/" + fullFileName);
+            userModelService.save(new_modelEntity);
         }
         return Result.success();
     }

+ 199 - 224
src/main/java/com/kexun/controller/ModelController.java

@@ -47,43 +47,42 @@ public class ModelController {
     private FilterResultService parseResultService;
 
 
-    private JsonFile jsonFile=new JsonFile();
+    private JsonFile jsonFile = new JsonFile();
 
     //给模型复核员提供模型复核
     @GetMapping("listUser")
-    public Result listUser(SysUser sysUser)
-    {
+    public Result listUser(SysUser sysUser) {
         QueryWrapper<SysUser> w = new QueryWrapper<>();
-        w.eq("role_id",4);
-        List<SysUser> list=sysUserService.list(w);
-        List<JSONObject> user_list =new ArrayList<>();
-        for(int i=0;i<list.size();i++)
-        {
-            String user_name=list.get(i).getUserName();
-            JSONObject user_json=new JSONObject();
-            List<UserModel> model_list=userModelService.findByUserName(user_name);
-            UserField userField=userFieldService.findByUserName(user_name);
-
-            user_json.put("userName",user_name);
-            user_json.put("modelList",model_list);
-            user_json.put("userField",userField);
+        w.eq("role_id", 4);
+        List<SysUser> list = sysUserService.list(w);
+        List<JSONObject> user_list = new ArrayList<>();
+        for (int i = 0; i < list.size(); i++) {
+            String user_name = list.get(i).getUserName();
+            JSONObject user_json = new JSONObject();
+            List<ModelEntity> model_Entity_list = userModelService.findByUserName(user_name);
+            UserField userField = userFieldService.findByUserName(user_name);
+
+            user_json.put("userName", user_name);
+            user_json.put("modelList", model_Entity_list);
+            user_json.put("userField", userField);
             user_list.add(user_json);
         }
-        return Result.success("ok",user_list);
+        return Result.success("ok", user_list);
     }
 
 
     @GetMapping("getApproval")
-    public Result getApproval()
-    {
-        JSONObject resJson=new JSONObject();
-        List<UserApproval> approval_list=userApprovalService.list();
-        resJson.put("approval_list",approval_list);
-        return Result.success("ok",resJson);
+    public Result getApproval() {
+        JSONObject resJson = new JSONObject();
+        List<UserApproval> approval_list = userApprovalService.list();
+        resJson.put("approval_list", approval_list);
+        return Result.success("ok", resJson);
 
     }
+
     /**
      * 读取json文件,返回json串
+     *
      * @param fileName
      * @return
      */
@@ -96,7 +95,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);
             }
 
@@ -109,16 +108,17 @@ public class ModelController {
             return null;
         }
     }
+
     private static String getType(Object a) {
         return a.getClass().toString();
     }
 
     //上传字段组合
     @PostMapping("addField")
-    public Result addField(@RequestBody String json,SysUser sysUser) throws IOException {
+    public Result addField(@RequestBody String json, SysUser sysUser) throws IOException {
         JSONObject req = JSON.parseObject(json);
 
-        String field_combine=req.getString("fieldcombine");
+        String field_combine = req.getString("fieldcombine");
 
         //添加异常判断,重名模型名?,yuan尚未实现,先忽略掉
 //        JSONObject resJson = new JSONObject();
@@ -130,8 +130,8 @@ public class ModelController {
 //        resJson.put("state", 1);
 
 //        此为自定义字段组合所需数据
-        String userName=req.getString("username");
-        String fieldData=req.getString("fielddata");
+        String userName = req.getString("username");
+        String fieldData = req.getString("fielddata");
 //        String fieldCombine = req.getString("fieldcombine");
         String fieldRemark = req.getString("remark");
 //        customizedModel.setModelName(modelName);
@@ -208,7 +208,7 @@ public class ModelController {
 //            userFieldService.updateById(userField);
 //        }
 //yuan
-        UserApproval approval=new UserApproval();
+        UserApproval approval = new UserApproval();
         approval.setUserName(sysUser.getUserName());
         approval.setApprovalId((long) 2);
         approval.setData(field_combine);
@@ -222,20 +222,21 @@ public class ModelController {
     //yuan 前端获取user_field表的信息,但是在获取id时,会进行四舍五入操作导致id错误,因此通过字段组合名更新
     @GetMapping("fieldCombineList")
     public Result fieldCombineList() {
-        JSONObject resJson=new JSONObject();
-        List<UserField> list=userFieldService.list();
-        resJson.put("field_combine_list",list);
-        return Result.success("ok",resJson);
+        JSONObject resJson = new JSONObject();
+        List<UserField> list = userFieldService.list();
+        resJson.put("field_combine_list", list);
+        return Result.success("ok", resJson);
 
     }
+
     // sxr
     @PostMapping("updateFieldCombineList")
-    public Result updateFieldCombineList(@RequestBody String json,SysUser sysUser) {
+    public Result updateFieldCombineList(@RequestBody String json, SysUser sysUser) {
         JSONObject req = JSON.parseObject(json);
 
-        long fieldId=Long.valueOf(req.getString("fieldId")) ;
-        String fieldCombine=req.getString("fieldCombine");
-        String choseData=req.getString("choseData");
+        long fieldId = Long.valueOf(req.getString("fieldId"));
+        String fieldCombine = req.getString("fieldCombine");
+        String choseData = req.getString("choseData");
 
         UserField userField = userFieldService.findByID(fieldId);
         userField.setFieldCombine(fieldCombine);
@@ -249,7 +250,7 @@ public class ModelController {
     // sxr
     @GetMapping("getFieldById")
     public Result getFieldById(Long fieldId) {
-        System.out.println( fieldId);
+        System.out.println(fieldId);
         JSONObject result = new JSONObject();
         UserField userField = userFieldService.findByID(fieldId);
 
@@ -258,30 +259,31 @@ public class ModelController {
 
         JSONObject fieldDateJson = new JSONObject();
         String fieldData = userField.getFieldData();
-        fieldData = fieldData.substring(1,fieldData.length()-1);
+        fieldData = fieldData.substring(1, fieldData.length() - 1);
         String[] temp = fieldData.split("]");
-        for(int i=0;i< temp.length;i++)
-        {
+        for (int i = 0; i < temp.length; i++) {
             System.out.println(temp[i]);
-            String key="";
-            if(i==0){  key = temp[i].split(":")[0].substring(1, temp[i].split(":")[0].length()-1);}
-            else{  key = temp[i].split(":")[0].substring(2, temp[i].split(":")[0].length()-1);}
+            String key = "";
+            if (i == 0) {
+                key = temp[i].split(":")[0].substring(1, temp[i].split(":")[0].length() - 1);
+            } else {
+                key = temp[i].split(":")[0].substring(2, temp[i].split(":")[0].length() - 1);
+            }
             String valuetmp[] = (temp[i].split(":")[1].substring(1).split(","));
             String value[] = {};
-            for(int j=0;j<valuetmp.length;j++)
-            {
+            for (int j = 0; j < valuetmp.length; j++) {
 
-                System.out.println( valuetmp[j]);
+                System.out.println(valuetmp[j]);
                 System.out.println(valuetmp[j].length());
 
-                valuetmp[j] = valuetmp[j].substring(1,valuetmp[j].length()-1);
+                valuetmp[j] = valuetmp[j].substring(1, valuetmp[j].length() - 1);
             }
 
             fieldDateJson.put(key, valuetmp);
 
         }
         System.out.println(fieldDateJson);
-        result.put("fieldData",fieldDateJson);
+        result.put("fieldData", fieldDateJson);
 //        System.out.println(userField.getFieldData());
         return Result.success("ok", result);
     }
@@ -362,155 +364,146 @@ public class ModelController {
 //    }
 
     @GetMapping("getField")
-    public Result getField(SysUser sysUser)
-    {
+    public Result getField(SysUser sysUser) {
         JSONObject resJson = new JSONObject();
-        String userName=sysUser.getUserName();
-        UserField userField=userFieldService.findByUserName(userName);
-        if(userField==null)
-        {
-            resJson.put("fieldData","暂无申请字段");
-            resJson.put("fieldState","未配置字段");
+        String userName = sysUser.getUserName();
+        UserField userField = userFieldService.findByUserName(userName);
+        if (userField == null) {
+            resJson.put("fieldData", "暂无申请字段");
+            resJson.put("fieldState", "未配置字段");
+        } else {
+            resJson.put("fieldData", userField.getFieldData());
+            resJson.put("fieldState", userField.getFieldState());
         }
-        else
-        {
-            resJson.put("fieldData",userField.getFieldData());
-            resJson.put("fieldState",userField.getFieldState());
-        }
-        return Result.success("ok",resJson);
+        return Result.success("ok", resJson);
     }
 
     @PostMapping("getFieldByName")
-    public Result getFieldByName(@RequestBody String json)
-    {
-        JSONObject req=JSON.parseObject(json);
+    public Result getFieldByName(@RequestBody String json) {
+        JSONObject req = JSON.parseObject(json);
         JSONObject resJson = new JSONObject();
-        String userName= req.getString("username");
-        UserField userField=userFieldService.findByUserName(userName);
-        if(userField==null)
-        {
-            resJson.put("fieldData","暂无申请字段");
-            resJson.put("fieldState","未配置字段");
+        String userName = req.getString("username");
+        UserField userField = userFieldService.findByUserName(userName);
+        if (userField == null) {
+            resJson.put("fieldData", "暂无申请字段");
+            resJson.put("fieldState", "未配置字段");
+        } else {
+            resJson.put("fieldData", userField.getFieldData());
+            resJson.put("fieldState", userField.getFieldState());
         }
-        else
-        {
-            resJson.put("fieldData",userField.getFieldData());
-            resJson.put("fieldState",userField.getFieldState());
-        }
-        return Result.success("ok",resJson);
+        return Result.success("ok", resJson);
     }
 
 
     //新增自定义模型
     @PostMapping("addModel")
-    public Result addModel(@RequestBody String json,SysUser sysUser) throws IOException {
+    public Result addModel(@RequestBody String json, SysUser sysUser) throws IOException {
         //获取用户模型,并按json文件保存
         JSONObject req = JSON.parseObject(json);
-        String model_name=req.getString("modelname");
+        String model_name = req.getString("modelname");
         JSONObject resJson = new JSONObject();
         //添加异常判断,重名模型名?
-        if(userModelService.findByUserAndModel(sysUser.getUserName(),model_name)!=null) {
+        if (userModelService.findByUserAndModel(sysUser.getUserName(), model_name) != null) {
             resJson.put("state", 0);
-            return Result.success("ok",resJson);
+            return Result.success("ok", resJson);
         }
         //非重名
         resJson.put("state", 1);
 
-        String model_data=req.getString("modeldata");
-        JSONObject model_json=JSON.parseObject(model_data);
+        String model_data = req.getString("modeldata");
+        JSONObject model_json = JSON.parseObject(model_data);
 
 //        String select_data = model_json.getJSONArray("select_data").toString();
 
-        String file_name=sysUser.getUserName()+"_"+model_name;
-        jsonFile.writerFile(model_json,file_name);
+        String file_name = sysUser.getUserName() + "_" + model_name;
+        jsonFile.writerFile(model_json, file_name);
 
         //  这个地方应该先加到审批页面上
-        UserApproval approval=new UserApproval();
+        UserApproval approval = new UserApproval();
         approval.setUserName(sysUser.getUserName());
         approval.setApprovalId((long) 1);
         approval.setData(model_name);
         userApprovalService.save(approval);
         //写入数据库
-        String userName=sysUser.getUserName();
-        UserModel new_model=new UserModel();
-        new_model.setCreateBy(userName);
-        new_model.setModelName(model_name);
-        new_model.setModelType(0);
-        new_model.setStatus("审批中");
+        String userName = sysUser.getUserName();
+        ModelEntity new_modelEntity = new ModelEntity();
+        new_modelEntity.setCreateBy(sysUser.getId());
+        new_modelEntity.setModelName(model_name);
+        new_modelEntity.setModelType(0);
+        new_modelEntity.setStatus("审批中");
 //        new_model.setFieldCombine("暂未指定");
-        new_model.setModelRule(model_data);
-        userModelService.save(new_model);
+        new_modelEntity.setModelRule(model_data);
+        userModelService.save(new_modelEntity);
 
 
-        return Result.success("ok",resJson);
+        return Result.success("ok", resJson);
 
     }
+
     //列举usermodel
     @GetMapping("getUserModel")
-    public Result getUserModel(SysUser sysUser)
-    {
-        JSONObject resJson=new JSONObject();
-        List<UserModel> model_list=userModelService.findByUserName(sysUser.getUserName());
+    public Result getUserModel(SysUser sysUser) {
+        JSONObject resJson = new JSONObject();
+        List<ModelEntity> model_Entity_list = userModelService.findByUserName(sysUser.getUserName());
 //        System.out.println(model_list.get(0).getId());
-        resJson.put("modelData", model_list);
+        resJson.put("modelData", model_Entity_list);
 
-        return Result.success("ok",resJson);
+        return Result.success("ok", resJson);
 
 
     }
+
     //    获取当前模型
     @PostMapping("getModelByName")
-    public Result getModelByName(@RequestBody String json,SysUser sysUser)
-    {
+    public Result getModelByName(@RequestBody String json, SysUser sysUser) {
 
-        JSONObject resJson=new JSONObject();
+        JSONObject resJson = new JSONObject();
 
         JSONObject req = JSON.parseObject(json);
         //user_name+model_name就是文件名
-        String model_name=req.getString("modelName");
-        String user_name=sysUser.getUserName();
+        String model_name = req.getString("modelName");
+        String user_name = sysUser.getUserName();
         //读取对应文件
-        JSONObject model=jsonFile.ReadJson(user_name+"_"+model_name);
+        JSONObject model = jsonFile.ReadJson(user_name + "_" + model_name);
         System.out.println(model);
 
 //        resJson.put("model", model);
 
-        return Result.success("ok",resJson);
+        return Result.success("ok", resJson);
 
     }
 
 
     @PostMapping("changeModelByID")
-    public Result changeModelByID(@RequestBody String json,SysUser sysUser) throws IOException {
+    public Result changeModelByID(@RequestBody String json, SysUser sysUser) throws IOException {
         //获取参数
-        JSONObject resJson=new JSONObject();
-        JSONObject req=JSON.parseObject(json);
-        String model_name=req.getString("modelname");
-        String model_data=req.getString("modeldata");
-        long id=Long.parseLong( req.getString("modelid"));
+        JSONObject resJson = new JSONObject();
+        JSONObject req = JSON.parseObject(json);
+        String model_name = req.getString("modelname");
+        String model_data = req.getString("modeldata");
+        long id = Long.parseLong(req.getString("modelid"));
 //        System.out.println(id);
 //        System.out.println(req.getString("modelid"));
-        UserModel model=userModelService.findByID(id);
+        ModelEntity modelEntity = userModelService.findByID(id);
 
         //删除旧模型(文件)
-        String old_name=model.getModelName();
+        String old_name = modelEntity.getModelName();
 
 
         //新模型写入
-        JSONObject model_json=JSON.parseObject(model_data);
-        String file_name=sysUser.getUserName()+"_"+model_name;
-        jsonFile.writerFile(model_json,file_name);
-        model.setModelName(model_name);
-        model.setStatus("审批中");
+        JSONObject model_json = JSON.parseObject(model_data);
+        String file_name = sysUser.getUserName() + "_" + model_name;
+        jsonFile.writerFile(model_json, file_name);
+        modelEntity.setModelName(model_name);
+        modelEntity.setStatus("审批中");
         //重新审批
-        UserApproval approval=new UserApproval();
+        UserApproval approval = new UserApproval();
         approval.setUserName(sysUser.getUserName());
         approval.setApprovalId((long) 1);
         approval.setData(model_name);
         userApprovalService.save(approval);
 
-        userModelService.updateById(model);
-
+        userModelService.updateById(modelEntity);
 
 
         return Result.success();
@@ -519,40 +512,40 @@ public class ModelController {
 
     //修改产品号
     @PostMapping("changeProduct")
-    public Result changeProduct(@RequestBody String json,SysUser sysUser)
-    {
-        JSONObject req=JSON.parseObject(json);
-        long id= Long.parseLong(req.getString("modelid"));
-        String productNum=req.getString("productnum");
-        UserModel model=userModelService.findByID(id);
-        model.setModelNo(productNum);
-        userModelService.updateById(model);
+    public Result changeProduct(@RequestBody String json, SysUser sysUser) {
+        JSONObject req = JSON.parseObject(json);
+        long id = Long.parseLong(req.getString("modelid"));
+        String productNum = req.getString("productnum");
+        ModelEntity modelEntity = userModelService.findByID(id);
+        modelEntity.setModelNo(productNum);
+        userModelService.updateById(modelEntity);
         return Result.success();
 
     }
+
     //mqy add changeModelName
     @PostMapping("changeModelName")
-    public Result changeModelName(@RequestBody String json){
-        JSONObject req=JSON.parseObject(json);
-        long modelNo= Long.parseLong(req.getString("modelNo"));
-        String modelName=req.getString("modelName");
+    public Result changeModelName(@RequestBody String json) {
+        JSONObject req = JSON.parseObject(json);
+        long modelNo = Long.parseLong(req.getString("modelNo"));
+        String modelName = req.getString("modelName");
         System.out.println(modelNo);
         System.out.println(modelName);
-        userModelService.changeModelName(modelName,modelNo);
+        userModelService.changeModelName(modelName, modelNo);
         return Result.success("ok");
     }
+
     //yuan修改组合对应模型号
     @PostMapping("combineReleModel")
-    public Result combineReleModel(@RequestBody String json,SysUser sysUser)
-    {
-        JSONObject req=JSON.parseObject(json);
-        String field_combine=req.getString("field_combine");
-        String modelName=req.getString("model_name");
-        UserField field=userFieldService.findByFieldCombine(field_combine);
-        UserModel model = userModelService.findByModelName(modelName);
+    public Result combineReleModel(@RequestBody String json, SysUser sysUser) {
+        JSONObject req = JSON.parseObject(json);
+        String field_combine = req.getString("field_combine");
+        String modelName = req.getString("model_name");
+        UserField field = userFieldService.findByFieldCombine(field_combine);
+        ModelEntity modelEntity = userModelService.findByModelName(modelName);
 //        model.setFieldCombine(field_combine);
         field.setModelName(modelName);
-        userModelService.updateById(model);
+        userModelService.updateById(modelEntity);
         userFieldService.updateById(field);
         return Result.success();
     }
@@ -576,28 +569,26 @@ public class ModelController {
     //这个接口是将模型从审核通过/暂停改为上线
 //    审批中/已上线/审核通过/暂停使用
     @PostMapping("changeState")
-    public Result changeState(@RequestBody String json,SysUser sysUser)
-    {
-        JSONObject req=JSON.parseObject(json);
-        long id= Long.parseLong(req.getString("modelid"));
-        String state=req.getString("modelstate");
+    public Result changeState(@RequestBody String json, SysUser sysUser) {
+        JSONObject req = JSON.parseObject(json);
+        long id = Long.parseLong(req.getString("modelid"));
+        String state = req.getString("modelstate");
 
         System.out.println(id);
-        UserModel model=userModelService.findByID(id);
+        ModelEntity modelEntity = userModelService.findByID(id);
 
-        model.setStatus(state);
+        modelEntity.setStatus(state);
 
-        userModelService.updateById(model);
+        userModelService.updateById(modelEntity);
 
         return Result.success();
 
     }
 
     @PostMapping("deleteModel")
-    public Result deleteModel(@RequestBody String json,SysUser sysUser)
-    {
-        JSONObject req=JSON.parseObject(json);
-        long id= Long.parseLong(req.getString("modelid"));
+    public Result deleteModel(@RequestBody String json, SysUser sysUser) {
+        JSONObject req = JSON.parseObject(json);
+        long id = Long.parseLong(req.getString("modelid"));
         String fieldCombine = req.getString("fieldCombine");
 //        if(fieldCombine.equals("暂未指定")){
 //
@@ -607,8 +598,8 @@ public class ModelController {
 //            userFieldService.updateById(field);
 //        }
 
-        UserModel model=userModelService.findByID(id);
-        String oldFilePath=model.getFilePath();
+        ModelEntity modelEntity = userModelService.findByID(id);
+        String oldFilePath = modelEntity.getFilePath();
         File oldFile = new File(oldFilePath);
 
         if (oldFile.exists()) {
@@ -618,8 +609,7 @@ public class ModelController {
             } catch (IOException e) {
                 System.out.println("file delete fail: " + e.getMessage());
             }
-        }
-        else {
+        } else {
             System.out.println("file not exist");
         }
 
@@ -630,21 +620,21 @@ public class ModelController {
 
     // 获取审核模块的详情,主要是模型详情
     @PostMapping("getDetails")
-    public Result getDetails(@RequestBody String json)
-    {
-        JSONObject jsonrq=JSON.parseObject(json);
-        int type=jsonrq.getInteger("type");
-        if(type==1)
-        {
+    public Result getDetails(@RequestBody String json) {
+        JSONObject jsonrq = JSON.parseObject(json);
+        int type = jsonrq.getInteger("type");
+        if (type == 1) {
             //首先获取对应模型
             JSONObject res = new JSONObject();
-            String user_name=jsonrq.getString("username");
-            String model_name=jsonrq.getString("modelname");
-            UserModel model=userModelService.findByUserAndModel(user_name,model_name);
-            if(model==null)   return Result.error();
+            String user_name = jsonrq.getString("username");
+            String model_name = jsonrq.getString("modelname");
+            ModelEntity modelEntity = userModelService.findByUserAndModel(user_name, model_name);
+            if (modelEntity == null) {
+                return Result.error();
+            }
             //模型类型
-            res.put("model_type",model.getModelType());
-            if(model.getModelType()==0) {//自定义模型
+            res.put("model_type", modelEntity.getModelType());
+            if (modelEntity.getModelType() == 0) {//自定义模型
                 JSONObject model_data = jsonFile.ReadJson(user_name + "_" + model_name);
                 if (model_data != null) {
                     res.put("error_code", 0);
@@ -654,90 +644,75 @@ public class ModelController {
                     res.put("error_info", "模型不存在!");
 
                 }
-            }
-            else if(model.getModelType()==1 || model.getModelType()==2)
-            {
+            } else if (modelEntity.getModelType() == 1 || modelEntity.getModelType() == 2) {
                 //res.put("output_list",model.getOutputList());
                 //res.put("other_data",model.getOtherData());
 
             }
-            return Result.success("ok",res);
-        }
-        else if(type==2)
-        {
+            return Result.success("ok", res);
+        } else if (type == 2) {
             //字段信息 直接获取 不用这一步
 //            JSONObject res = new JSONObject();
 //            String user_name=jsonrq.getString("username");
 //            String field_data=jsonrq.getString("modelname");
 
-        }
-        else
-        {
+        } else {
 
         }
         return Result.success();
     }
 
     @PostMapping("doApproval")
-    public Result doApproval(@RequestBody String json)
-    {
-        String reason_list[]={"错误字段选择","错误模型逻辑","其他"};
-        JSONObject jsonrq=JSON.parseObject(json);
-        int type=jsonrq.getInteger("type");
-        long id= Long.parseLong(jsonrq.getString("id"));
-
-        if(type==1)
-        {
+    public Result doApproval(@RequestBody String json) {
+        String reason_list[] = {"错误字段选择", "错误模型逻辑", "其他"};
+        JSONObject jsonrq = JSON.parseObject(json);
+        int type = jsonrq.getInteger("type");
+        long id = Long.parseLong(jsonrq.getString("id"));
+
+        if (type == 1) {
             JSONObject res = new JSONObject();
-            String user_name=jsonrq.getString("username");
-            String model_name=jsonrq.getString("data");
-            int pass=jsonrq.getInteger("pass");
+            String user_name = jsonrq.getString("username");
+            String model_name = jsonrq.getString("data");
+            int pass = jsonrq.getInteger("pass");
             //通过
-            if(pass==1)
-            {
-                UserModel model=userModelService.findByUserAndModel(user_name,model_name);
-                if(model!=null) {
-                    model.setStatus("审核通过");
-                    userModelService.updateById(model);
+            if (pass == 1) {
+                ModelEntity modelEntity = userModelService.findByUserAndModel(user_name, model_name);
+                if (modelEntity != null) {
+                    modelEntity.setStatus("审核通过");
+                    userModelService.updateById(modelEntity);
                 }
             }
             //不通过
             else {
-                int reason=jsonrq.getInteger("reason");
-                UserModel model = userModelService.findByUserAndModel(user_name, model_name);
-                if(model!=null) {
-                    model.setStatus("审核不通过:"+reason_list[reason]);
-                    userModelService.updateById(model);
+                int reason = jsonrq.getInteger("reason");
+                ModelEntity modelEntity = userModelService.findByUserAndModel(user_name, model_name);
+                if (modelEntity != null) {
+                    modelEntity.setStatus("审核不通过:" + reason_list[reason]);
+                    userModelService.updateById(modelEntity);
                 }
             }
-        }
-        else if(type==2)
-        {
-            String user_name=jsonrq.getString("username");
-            String user_field=jsonrq.getString("data");
-            int pass=jsonrq.getInteger("pass");
+        } else if (type == 2) {
+            String user_name = jsonrq.getString("username");
+            String user_field = jsonrq.getString("data");
+            int pass = jsonrq.getInteger("pass");
 
             System.out.println("审核了字段");
             System.out.println(user_name);
-            if(pass==1)
-            {
-                UserField userField=userFieldService.findByFieldCombine(user_field);
-                if(userField!=null) {
+            if (pass == 1) {
+                UserField userField = userFieldService.findByFieldCombine(user_field);
+                if (userField != null) {
                     userField.setFieldState("审核通过");
                     userFieldService.updateById(userField);
                 }
 
-            }
-            else {
-                UserField userField=userFieldService.findByUserName(user_name);
-                if(userField!=null) {
+            } else {
+                UserField userField = userFieldService.findByUserName(user_name);
+                if (userField != null) {
                     userField.setFieldState("审核不通过");
                     userFieldService.updateById(userField);
                 }
             }
-        }
-        else
-        {
+        } else {
 
         }
         System.out.println(id);

+ 14 - 24
src/main/java/com/kexun/entity/UserModel.java → src/main/java/com/kexun/entity/ModelEntity.java

@@ -1,4 +1,5 @@
 package com.kexun.entity;
+
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -9,51 +10,40 @@ import lombok.Data;
 import java.io.Serializable;
 import java.util.Date;
 
+/**
+ * Description: 模型实体类
+ *
+ * @author lgs
+ * @date 2023/12/08
+ */
 @TableName(value = "model")
 @Data
-public class UserModel implements Serializable {
-    @JsonSerialize(using = ToStringSerializer.class)
-    @TableId(value = "id")
-    private Long id;
-
-    @TableField(value = "create_by")
-    private String createBy;
+public class ModelEntity extends BaseEntity implements Serializable {
 
     @TableField(value = "model_name")
     private String modelName;
 
-//    @TableField(value = "field_combine")
-//    private String fieldCombine;
-
     @TableField(value = "model_no")
     private String modelNo;
 
     @TableField(value = "status")
     private String status;
 
-    //    0  自定义模型
-//    1  jar包
-//    2  python包
-//    3  http服务
+    /**
+     * 0  自定义模型
+     * 1  jar包
+     * 2  python包
+     * 3  http服务
+     */
     @TableField(value = "model_type")
     private int modelType;
 
-
-//    @TableField(value = "other_data")
-//    private String otherData;
-
-//    @TableField(value = "output_list")
-//    private String outputList;
-
     @TableField(value = "model_rule")
     private String modelRule;
 
     @TableField(value = "file_path")
     private String filePath;
 
-    @TableField(value = "create_time")
-    private String createTime;
-
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
 

+ 2 - 2
src/main/java/com/kexun/mapper/UserModelMapper.java

@@ -1,9 +1,9 @@
 package com.kexun.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.kexun.entity.UserModel;
+import com.kexun.entity.ModelEntity;
 import org.springframework.data.repository.query.Param;
 
-public interface UserModelMapper extends BaseMapper<UserModel> {
+public interface UserModelMapper extends BaseMapper<ModelEntity> {
     void changeModelNameQuery(@Param("modelName") String modelName, @Param("modelNo") long modelNo);
 }

+ 0 - 1
src/main/java/com/kexun/service/UserFieldService.java

@@ -2,7 +2,6 @@ package com.kexun.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.kexun.entity.UserField;
-import com.kexun.entity.UserModel;
 
 public interface UserFieldService extends IService<UserField> {
     UserField findByUserName(String user_name);

+ 6 - 7
src/main/java/com/kexun/service/UserModelService.java

@@ -1,17 +1,16 @@
 package com.kexun.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.kexun.entity.UserField;
-import com.kexun.entity.UserModel;
+import com.kexun.entity.ModelEntity;
 
 import java.util.List;
 
-public interface UserModelService extends IService<UserModel> {
+public interface UserModelService extends IService<ModelEntity> {
 
-    List<UserModel> findByUserName(String user_name);
-    UserModel findByModelName(String model_name);
-    UserModel findByUserAndModel(String user_name,String model_name);
-    UserModel findByID(long id);
+    List<ModelEntity> findByUserName(String user_name);
+    ModelEntity findByModelName(String model_name);
+    ModelEntity findByUserAndModel(String user_name, String model_name);
+    ModelEntity findByID(long id);
     void removeModelByID(long id);
 
     void changeModelName(String modelName,long modelNo);

+ 0 - 1
src/main/java/com/kexun/service/impl/UserFieldServiceImpl.java

@@ -3,7 +3,6 @@ package com.kexun.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.kexun.entity.UserField;
-import com.kexun.entity.UserModel;
 import com.kexun.mapper.UserFieldMapper;
 import com.kexun.service.UserFieldService;
 import org.springframework.stereotype.Service;

+ 13 - 14
src/main/java/com/kexun/service/impl/UserModelServiceImpl.java

@@ -2,8 +2,7 @@ package com.kexun.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.kexun.entity.UserModel;
-import com.kexun.mapper.CooperatorProductMapper;
+import com.kexun.entity.ModelEntity;
 import com.kexun.mapper.UserModelMapper;
 import com.kexun.service.UserModelService;
 import org.springframework.stereotype.Service;
@@ -11,47 +10,47 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.util.List;
 @Service
-public class UserModelServiceImpl extends ServiceImpl<UserModelMapper,UserModel>
+public class UserModelServiceImpl extends ServiceImpl<UserModelMapper, ModelEntity>
         implements UserModelService
 {
     @Resource
     UserModelMapper userModelMapper;
     @Override
-    public List<UserModel> findByUserName(String user_name) {
+    public List<ModelEntity> findByUserName(String user_name) {
 
-        QueryWrapper<UserModel> wrapper=new QueryWrapper<UserModel>().eq("create_by",user_name);
-        List<UserModel> model_list=list(wrapper);
-        return model_list;
+        QueryWrapper<ModelEntity> wrapper=new QueryWrapper<ModelEntity>().eq("create_by",user_name);
+        List<ModelEntity> model_Entity_list =list(wrapper);
+        return model_Entity_list;
     }
 
     @Override
 
-    public UserModel findByModelName(String model_name)
+    public ModelEntity findByModelName(String model_name)
     {
-        QueryWrapper<UserModel> wrapper=new QueryWrapper<UserModel>().eq("model_name",model_name);
+        QueryWrapper<ModelEntity> wrapper=new QueryWrapper<ModelEntity>().eq("model_name",model_name);
 
         return getOne(wrapper);
 
     }
     @Override
 
-    public UserModel findByUserAndModel(String user_name,String model_name)
+    public ModelEntity findByUserAndModel(String user_name, String model_name)
     {
-        QueryWrapper<UserModel> wrapper=new QueryWrapper<UserModel>().eq("create_by",user_name);
+        QueryWrapper<ModelEntity> wrapper=new QueryWrapper<ModelEntity>().eq("create_by",user_name);
         wrapper.eq("model_name",model_name);
         return getOne(wrapper);
 
     }
 
     @Override
-    public UserModel findByID(long id) {
-        QueryWrapper<UserModel> wrapper=new QueryWrapper<UserModel>().eq("id",id);
+    public ModelEntity findByID(long id) {
+        QueryWrapper<ModelEntity> wrapper=new QueryWrapper<ModelEntity>().eq("id",id);
         return getOne(wrapper);
     }
 
     @Override
     public void removeModelByID(long id) {
-        QueryWrapper<UserModel> wrapper=new QueryWrapper<UserModel>().eq("id",id);
+        QueryWrapper<ModelEntity> wrapper=new QueryWrapper<ModelEntity>().eq("id",id);
         remove(wrapper);
     }
     @Override

+ 1 - 1
src/main/resources/mapper/UserModelMapper.xml

@@ -4,7 +4,7 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.kexun.mapper.UserModelMapper">
 
-    <resultMap id="BaseResultMap" type="com.kexun.entity.UserModel">
+    <resultMap id="BaseResultMap" type="com.kexun.entity.ModelEntity">
         <id property="id" column="id" jdbcType="BIGINT"/>
         <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
         <result property="modelName" column="model_name" jdbcType="VARCHAR"/>