6 yıl önce
ebeveyn
işleme
233c255782

+ 16 - 1
pcbms/src/main/java/com/hssx/pcbms/controller/GoodsController.java

@@ -95,7 +95,6 @@ public class GoodsController {
      * 参数:
      * name :名称,keyName:关键字,pageNum:当前页,pageSize:每页多少条
      * tagId:标签id(单个标签)(查看全部不传)
-     * uid :查看我的资产时传当前人的id
      * @return
      */
     @ApiOperation(value = "资产列表", notes = "资产列表方法")
@@ -107,6 +106,22 @@ public class GoodsController {
         HttpRespMsg msg = goodsService.getList(page, keyName, tagId,uid);
         return msg;
     }
+    /**
+     * 我的资产列表
+     * 参数:
+     * name :名称,keyName:关键字,pageNum:当前页,pageSize:每页多少条
+     * uid:所属人id
+     * @return
+     */
+    @ApiOperation(value = "我的资产列表", notes = "我的资产列表方法")
+    @RequestMapping("/myList")
+    @ResponseBody
+    public HttpRespMsg myList(PageUtil page, @RequestParam(required = false) String keyName,
+                            @RequestParam(required = false)Integer tagId,
+                            @RequestParam(required = false)Integer uid) {
+        HttpRespMsg msg = goodsService.myList(page, keyName,uid);
+        return msg;
+    }
 
     /**
      * 资产详情

+ 3 - 0
pcbms/src/main/java/com/hssx/pcbms/entity/GoodsNo.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
 import java.io.Serializable;
 
 /**
@@ -71,6 +73,7 @@ public class GoodsNo extends Model<GoodsNo> {
      * 最后更新日期
      */
     @TableField("update_indate")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime updateIndate;
 
     /**

+ 2 - 2
pcbms/src/main/java/com/hssx/pcbms/entity/vo/GoodsVO.java

@@ -17,7 +17,7 @@ public class GoodsVO extends Goods {
     private Integer number = 0;//数量
     private String deptStr;//部门编号
     private String goodStr;//产品编号
-    private List<GoodsNo> goodsNosVO;
-    private List<GoodsNoVO> goodsNos;
+    private List<GoodsNo> goodsNos;
+    private List<GoodsNoVO> goodsNosVO;
     private Integer userId;
 }

+ 2 - 0
pcbms/src/main/java/com/hssx/pcbms/mapper/GoodsMapper.java

@@ -16,4 +16,6 @@ public interface GoodsMapper extends BaseMapper<Goods> {
     List<GoodsVO> getListBycondition(@Param("keyName") String keyName, @Param("tagId") Integer tagId,@Param("uid")Integer uid);
 
     GoodsVO getDetail(@Param("id")Integer id);
+
+    List<GoodsVO> selectMyList(@Param("start")Integer start, @Param("pageSize")Integer pageSize, @Param("uid")Integer uid);
 }

+ 2 - 0
pcbms/src/main/java/com/hssx/pcbms/service/GoodsService.java

@@ -47,4 +47,6 @@ public interface GoodsService extends IService<Goods> {
     HttpRespMsg isMaintainList(Goods goods);
 
     HttpRespMsg isMaintainRecord(Goods goods,PageUtil page);
+
+    HttpRespMsg myList(PageUtil page, String keyName, Integer uid);
 }

+ 15 - 0
pcbms/src/main/java/com/hssx/pcbms/service/impl/GoodsServiceImpl.java

@@ -277,6 +277,21 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         return msg;
     }
 
+    @Override
+    public HttpRespMsg myList(PageUtil page, String keyName, Integer uid) {
+        HttpRespMsg msg = new HttpRespMsg();
+        Integer start = (page.getPageNum()-1)*page.getPageSize();
+        List<GoodsVO> list = goodsMapper.selectMyList(start,page.getPageSize(),uid);
+        Integer total = goodsMapper.selectMyList(null,null,uid).size();
+        PageUtil<GoodsVO> pageInfo = new PageUtil<>();
+        pageInfo.setList(list);
+        pageInfo.setTotal(total);
+        pageInfo.setPageSize(page.getPageSize());
+        pageInfo.setPages(total);
+        msg.data = pageInfo;
+        return msg;
+    }
+
     public static void main(String[] args) {
 //        String format = String.format("%04d", 0);
 //        System.out.println(format);

+ 44 - 3
pcbms/src/main/resources/mapper/GoodsMapper.xml

@@ -39,6 +39,30 @@
                     ofType="com.hssx.pcbms.entity.GoodsNo">
         </collection>
     </resultMap>
+    <!-- 我的资产查询映射结果 -->
+    <resultMap id="BaseResultMapMyList" type="com.hssx.pcbms.entity.vo.GoodsVO">
+        <id column="id" property="id"/>
+        <result column="name" property="name"/>
+        <result column="tag_id" property="tagId"/>
+        <result column="model_number" property="modelNumber"/>
+        <result column="unit" property="unit"/>
+        <result column="address" property="address"/>
+        <result column="factory" property="factory"/>
+        <result column="pic" property="pic"/>
+        <result column="service_life" property="serviceLife"/>
+        <result column="next_indate" property="nextIndate"/>
+        <collection property="goodsNos" ofType="com.hssx.pcbms.entity.GoodsNo">
+            <id column="nid" property="id"/>
+            <result column="model_no" property="modelNo"/>
+            <result column="division_code" property="divisionCode"/>
+            <result column="suffix_code" property="suffixCode"/>
+            <result column="state" property="state"/>
+            <result column="indate" property="indate"/>
+            <result column="goods_id" property="goodsId"/>
+            <result column="user_id" property="userId"/>
+            <result column="is_maintain" property="isMaintain" />
+        </collection>
+    </resultMap>
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMapDetail" type="com.hssx.pcbms.entity.vo.GoodsVO">
@@ -79,9 +103,6 @@
             <if test="tagId != null">
                 and tag_id = #{tagId}
             </if>
-            <if test="uid != null">
-                and creator_id = #{uid}
-            </if>
         </where>
     </select>
     <select id="selectGoodsNoByGoodsId" resultType="com.hssx.pcbms.entity.GoodsNo">
@@ -108,4 +129,24 @@
             g.id = #{id}
         </where>
     </select>
+
+    <select id="selectMyList" resultMap="BaseResultMapMyList">
+        select
+        g.id, g.name, g.tag_id, g.model_number, g.unit,g.address, g.factory, g.pic, g.service_life, g.next_indate,
+        g.is_delete,gn.id nid,
+        gn.model_no, gn.division_code, gn.suffix_code, gn.state, gn.indate, gn.goods_id, gn.user_id,u.name username,gn.is_maintain,u.phone
+        from
+        goods g
+        left join
+        goods_no gn
+        on g.id = gn.goods_id
+        left join user u
+        on u.id = gn.user_id
+        <where>
+            AND gn.user_id = #{uid,jdbcType=INTEGER}
+        </where>
+        <if test="start != null and pageSize != null">
+            limit #{start,jdbcType=INTEGER} ,#{pageSize,jdbcType=INTEGER}
+        </if>
+    </select>
 </mapper>