Browse Source

零件的添加与修改

5 năm trước cách đây
mục cha
commit
1ed8ea03a9

+ 16 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/controller/PartController.java

@@ -75,5 +75,21 @@ public class PartController {
                 userVO);
         return msg;
     }
+    /**
+     * 单个零件添加
+     * 参数: token 用户身份凭证, mouldId 模具id
+     * @throws Exception
+     */
+    @ApiOperation("零件列表")
+    @RequestMapping(value = "/list")
+    @ResponseBody
+    public HttpRespMsg list(
+            Part part,
+            UserVO userVO) {
+        HttpRespMsg msg = new HttpRespMsg();
+        msg = partService.getList(
+                userVO);
+        return msg;
+    }
 }
 

+ 15 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/entity/vo/PartVO.java

@@ -0,0 +1,15 @@
+package com.hssx.cloudmodel.entity.vo;
+
+import com.hssx.cloudmodel.entity.MouldFile;
+import com.hssx.cloudmodel.entity.Part;
+
+/**
+ * Author: 吴涛涛 cuiyi@itany.com
+ * Date : 2019 - 08 - 13 15:22
+ * Description:<描述>
+ * Version: 1.0
+ */
+public class PartVO extends Part {
+    private MouldFile part2dFile;
+    private MouldFile part3dFile;
+}

+ 6 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/mapper/PartMapper.java

@@ -2,6 +2,11 @@ package com.hssx.cloudmodel.mapper;
 
 import com.hssx.cloudmodel.entity.Part;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.hssx.cloudmodel.entity.vo.PartVO;
+import com.hssx.cloudmodel.entity.vo.UserVO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +18,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface PartMapper extends BaseMapper<Part> {
 
+    List<PartVO> selectPartFileByMouldId(@Param("userVO") UserVO userVO);
 }

+ 2 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/service/PartService.java

@@ -21,4 +21,6 @@ public interface PartService extends IService<Part> {
     HttpRespMsg importPartExcel(MultipartFile file, UserVO userVO);
 
     HttpRespMsg add(Part part, UserVO userVO);
+
+    HttpRespMsg getList(UserVO userVO);
 }

+ 15 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/PartServiceImpl.java

@@ -5,6 +5,7 @@ import com.hssx.cloudmodel.entity.Company;
 import com.hssx.cloudmodel.entity.Mould;
 import com.hssx.cloudmodel.entity.Part;
 import com.hssx.cloudmodel.entity.User;
+import com.hssx.cloudmodel.entity.vo.PartVO;
 import com.hssx.cloudmodel.entity.vo.UserVO;
 import com.hssx.cloudmodel.mapper.MouldMapper;
 import com.hssx.cloudmodel.mapper.PartMapper;
@@ -141,6 +142,20 @@ public class PartServiceImpl extends ServiceImpl<PartMapper, Part> implements Pa
         return msg;
     }
 
+    @Override
+    public HttpRespMsg getList(UserVO userVO) {
+        HttpRespMsg msg = new HttpRespMsg();
+        User user = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", userVO.getToken()));
+        if(user != null){
+            List<PartVO> list = new ArrayList<>();
+            list = partMapper.selectPartFileByMouldId(userVO);
+            msg.data = list;
+        }else{
+            msg.setError("用户不存在或者未登录");
+        }
+        return msg;
+    }
+
     /**
      * 输入流转file
      *

+ 43 - 1
cloud-model/src/main/resources/mapper/PartMapper.xml

@@ -14,10 +14,52 @@
         <result column="creator" property="creator" />
         <result column="mould_id" property="mouldId" />
     </resultMap>
+    <resultMap id="BaseResultMapVO" type="com.hssx.cloudmodel.entity.vo.PartVO">
+        <id column="id" property="id" />
+        <result column="part_no" property="partNo" />
+        <result column="part_name" property="partName" />
+        <result column="indate" property="indate" />
+        <result column="part_life" property="partLife" />
+        <result column="is_vulnerable" property="isVulnerable" />
+        <result column="creator_id" property="creatorId" />
+        <result column="creator" property="creator" />
+        <result column="mould_id" property="mouldId" />
+        <association property="part2dFile" javaType="com.hssx.cloudmodel.entity.MouldFile" column="id" select="getPart2dFileByPartId">
+        </association>
+        <association property="part3dFile" javaType="com.hssx.cloudmodel.entity.MouldFile" column="id" select="getPart3dFileByPartId">
+        </association>
+    </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
         id, part_no, part_name, indate, part_life, is_vulnerable, creator_id, creator, mould_id
     </sql>
-
+    <select id="selectPartFileByMouldId" resultMap="BaseResultMapVO">
+        select
+          id, part_no, part_name, indate, part_life, is_vulnerable, creator_id, creator, mould_id
+        from
+          tb_mould_file
+        where
+          mould_id = #{userVO.mouldId}
+    </select>
+    <select id="getPart2dFileByPartId" resultType="com.hssx.cloudmodel.entity.MouldFile">
+        select
+            id, uplodtor_id, uploadtor, indate, model_id, sparepart_id,
+            project_id, file_url, file_name, blong_type, content, state,
+            file_type, file_size, dwg_type, part_id
+        from
+            tb_mould_file
+        where
+            part_id = #{id}
+    </select>
+    <select id="getPart3dFileByPartId" resultType="com.hssx.cloudmodel.entity.MouldFile">
+        select
+            id, uplodtor_id, uploadtor, indate, model_id, sparepart_id,
+            project_id, file_url, file_name, blong_type, content, state,
+            file_type, file_size, dwg_type, part_id
+        from
+            tb_mould_file
+        where
+            part_id = #{id}
+    </select>
 </mapper>