Explorar o código

fixed bugs in model

maqingyang hai 1 ano
pai
achega
b0c2e62466

+ 2 - 1
src/main/java/com/kexun/controller/FileUploadController.java

@@ -107,7 +107,7 @@ public class FileUploadController {
     @PostMapping("/fileupload")
     @ResponseBody
     public Result upload2(@RequestParam Integer index, @RequestParam MultipartFile chunk, @RequestParam String name, @RequestParam Integer chunksLength, @RequestParam String uid
-            , @RequestParam String model_name, @RequestParam String model_type, @RequestParam String output_list, SysUser sysUser
+            , @RequestParam String model_name, @RequestParam String model_type,@RequestParam String model_no, @RequestParam String output_list, SysUser sysUser
     ) throws IOException {
         int type = Integer.parseInt(model_type);
         if (type == 1 || type == 2) {
@@ -150,6 +150,7 @@ public class FileUploadController {
             new_modelEntity.setCreateBy(sysUser.getId());
             new_modelEntity.setModelName(model_name);
             new_modelEntity.setModelType(type);
+            new_modelEntity.setModelNo(model_no);
             new_modelEntity.setStatus("暂停使用");
 //            new_model.setOtherData(name);
 //            new_model.setOutputList(output_list);

+ 24 - 7
src/main/java/com/kexun/controller/ModelController.java

@@ -13,7 +13,9 @@ import com.kexun.service.*;
 import org.apache.commons.io.FileUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
-
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
 import java.io.*;
 import java.util.*;
 
@@ -50,7 +52,16 @@ public class ModelController {
 
 
     private JsonFile jsonFile = new JsonFile();
+    @GetMapping("getModelNo")
+    public Result getModelNo(){
+        JSONObject resJson = new JSONObject();
+        String model_no=userModelService.getModelNo();
+
+        System.out.println(model_no);
 
+        resJson.put("model_no", model_no);
+        return Result.success("ok", resJson);
+    }
     //给模型复核员提供模型复核
     @GetMapping("listUser")
     public Result listUser(SysUser sysUser) {
@@ -448,21 +459,23 @@ public class ModelController {
         JSONObject req = JSON.parseObject(json);
         int pageNum = req.getIntValue("pageNum");
         int pageSize = req.getIntValue("pageSize");
-        System.out.println(pageNum);
-        System.out.println(pageSize);
+//        System.out.println(pageNum);
+//        System.out.println(pageSize);
         PageHelper.startPage(pageNum, pageSize);//设置分页信息
         JSONObject resJson = new JSONObject();
+
         //List<ModelEntity> model_Entity_list = userModelService.findByUserName(sysUser.getUserName());
         //写死
 //        List<ModelEntity> model_Entity_list = userModelService.findByUserName("1");
 //        System.out.println(model_Entity_list);
-        List<ModelEntity> model_Entity_list = userModelService.getUserModel(1L);
+        List<ModelEntity> model_Entity_list = userModelService.getUserModel();
+//        System.out.println(model_Entity_list.get(0).getCreateTime());
+
         PageInfo pageInfo=new PageInfo(model_Entity_list);
-        System.out.println(pageInfo);
+//        System.out.println(pageInfo);
         resJson.put("modelData",pageInfo);
-        return Result.success("ok", resJson);
-
 
+        return Result.success("ok", resJson);
     }
 
     //    获取当前模型
@@ -587,8 +600,12 @@ public class ModelController {
         String state = req.getString("modelstate");
 
         System.out.println(id);
+        System.out.println(state);
         ModelEntity modelEntity = userModelService.findByID(id);
 
+        System.out.println(modelEntity);
+
+
         modelEntity.setStatus(state);
 
         userModelService.updateById(modelEntity);

+ 7 - 0
src/main/java/com/kexun/entity/ModelEntity.java

@@ -44,7 +44,14 @@ public class ModelEntity extends BaseEntity implements Serializable {
     @TableField(value = "file_path")
     private String filePath;
 
+//    @TableField(value = "create_by")
+//    private String userName;
+
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
 
+    public Date getCreateTime(){
+        return super.getCreateTime();
+    }
+
 }

+ 4 - 1
src/main/java/com/kexun/mapper/UserModelMapper.java

@@ -7,5 +7,8 @@ import java.util.List;
 public interface UserModelMapper extends BaseMapper<ModelEntity> {
     void changeModelNameQuery(@Param("modelName") String modelName, @Param("modelNo") long modelNo);
 
-    List<ModelEntity> getUserModelQuery(@Param("createBy") Long createBy);
+    List<ModelEntity> getUserModelQuery();
+
+    String getModelNo();
+
 }

+ 4 - 1
src/main/java/com/kexun/service/UserModelService.java

@@ -15,5 +15,8 @@ public interface UserModelService extends IService<ModelEntity> {
 
     void changeModelName(String modelName,long modelNo);
 
-    List<ModelEntity> getUserModel(Long createBy);
+    List<ModelEntity> getUserModel();
+
+    String getModelNo();
+
 }

+ 23 - 3
src/main/java/com/kexun/service/impl/UserModelServiceImpl.java

@@ -2,6 +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.common.Model;
 import com.kexun.entity.ModelEntity;
 import com.kexun.mapper.UserModelMapper;
 import com.kexun.service.UserModelService;
@@ -15,6 +16,21 @@ public class UserModelServiceImpl extends ServiceImpl<UserModelMapper, ModelEnti
 {
     @Resource
     UserModelMapper userModelMapper;
+
+//    public String getModelNoService(String userName) {
+//        QueryWrapper<ModelEntity> wrapper = new QueryWrapper<ModelEntity>()
+//                .eq("create_by", userName)
+//                .orderByDesc("id")
+//                .last("LIMIT 1");
+//
+//        ModelEntity lastModel = modelMapper.selectOne(wrapper);
+//
+//        if (lastModel != null) {
+//            return lastModel.getModelNo();
+//        } else {
+//            return null; // or handle the case when no data is found
+//        }
+//    }
     @Override
     public List<ModelEntity> findByUserName(String user_name) {
 
@@ -24,7 +40,6 @@ public class UserModelServiceImpl extends ServiceImpl<UserModelMapper, ModelEnti
     }
 
     @Override
-
     public ModelEntity findByModelName(String model_name)
     {
         QueryWrapper<ModelEntity> wrapper=new QueryWrapper<ModelEntity>().eq("model_name",model_name);
@@ -58,8 +73,13 @@ public class UserModelServiceImpl extends ServiceImpl<UserModelMapper, ModelEnti
         userModelMapper.changeModelNameQuery(modelName,modelNo);
     }
     @Override
-    public List<ModelEntity> getUserModel(Long createBy){
-        return userModelMapper.getUserModelQuery(createBy);
+    public List<ModelEntity> getUserModel(){
+        return userModelMapper.getUserModelQuery();
+    }
+
+    @Override
+    public String getModelNo(){
+        return userModelMapper.getModelNo();
     }
 
 }

+ 12 - 3
src/main/resources/mapper/UserModelMapper.xml

@@ -6,7 +6,7 @@
 
     <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="createBy" column="create_by" jdbcType="BIGINT"/>
         <result property="modelName" column="model_name" jdbcType="VARCHAR"/>
         <!--        <result property="fieldCombine" column="field_combine" jdbcType="VARCHAR"/>-->
         <result property="modelNo" column="model_no" jdbcType="VARCHAR"/>
@@ -18,7 +18,6 @@
         <result property="filePath" column="file_path" jdbcType="VARCHAR"/>
         <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
 
-
     </resultMap>
 
     <sql id="Base_Column_List">
@@ -32,8 +31,18 @@
         WHERE model.model_no=#{modelNo}
     </select>
 
+
     <select id="getUserModelQuery" resultType="com.kexun.entity.ModelEntity">
         SELECT * FROM model
-        WHERE create_by=#{createBy}
+        WHERE is_deleted = 0
+        ORDER BY create_time DESC
+    </select>
+
+    <resultMap id="modelNoMap" type="java.lang.String">
+        <id property="modelNo" column="model_no"/>
+    </resultMap>
+
+    <select id="getModelNo" resultMap="modelNoMap">
+        SELECT model_no FROM model ORDER BY model_no DESC LIMIT 1
     </select>
 </mapper>