Browse Source

资产详情

5 years ago
parent
commit
00ecbcd49d

+ 13 - 0
pcbms/src/main/java/com/hssx/pcbms/controller/GoodsController.java

@@ -35,6 +35,7 @@ public class GoodsController {
     /**
      * 资产录入
      * 参数:
+     * userId :当前登录人的id
      * name :名称,tagId:标签id,modelNumber:模具型号,company:公司
      * ,address:地址,factory:生产厂家,file:产品图片文件,serviceLife:服务期限(天),
      * nextIndate:下次维护日期,number:数量,deptStr:部门编号前缀,goodStr:产品编号前缀
@@ -79,6 +80,18 @@ public class GoodsController {
         HttpRespMsg msg = goodsService.getList(page,keyName,tagId);
         return msg;
     }
+    /**
+     * 资产详情
+     * 参数:id:资产id
+     * @return
+     */
+    @ApiOperation(value = "资产详情", notes = "资产详情方法")
+    @RequestMapping("/detail")
+    @ResponseBody
+    public HttpRespMsg detail(Integer id) {
+        HttpRespMsg msg = goodsService.getDetail(id);
+        return msg;
+    }
 
     /**
      * 资产基本信息的删除

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

@@ -18,4 +18,5 @@ public class GoodsVO extends Goods {
     private String deptStr;//部门编号
     private String goodStr;//产品编号
     private List<GoodsNo> goodsNos;
+    private Integer userId;
 }

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

@@ -14,4 +14,6 @@ import java.util.List;
 public interface GoodsMapper extends BaseMapper<Goods> {
 
     List<GoodsVO> getListBycondition(@Param("keyName") String keyName, @Param("tagId") Integer tagId);
+
+    GoodsVO getDetail(@Param("id")Integer id);
 }

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

@@ -27,4 +27,6 @@ public interface GoodsService extends IService<Goods> {
     HttpRespMsg del(Goods goods);
 
     HttpRespMsg delNo(GoodsNo goodsNo);
+
+    HttpRespMsg getDetail(Integer id);
 }

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

@@ -65,6 +65,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
                 goodsNo.setModelNo(mouldNo+String.format("%04d", i));
                 goodsNo.setSuffixCode(goodsVO.getGoodStr());
                 goodsNo.setDivisionCode(goodsVO.getDeptStr());
+                goodsNo.setUserId(goodsVO.getUserId());
                 list.add(goodsNo);
             }
             goodsNoService.saveBatch(list);
@@ -114,6 +115,14 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         return msg;
     }
 
+    @Override
+    public HttpRespMsg getDetail(Integer id) {
+        HttpRespMsg msg = new HttpRespMsg();
+        GoodsVO vo = goodsMapper.getDetail(id);
+        msg.data = vo;
+        return msg;
+    }
+
     public static void main(String[] args) {
         String format = String.format("%04d", 0);
         System.out.println(format);

+ 58 - 0
pcbms/src/main/resources/mapper/GoodsMapper.xml

@@ -22,4 +22,62 @@
         id, name, tag_id, model_number, unit, address, factory, pic, service_life, next_indate, is_delete
     </sql>
 
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMapVO" 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" select="selectGoodsNoByGoodsId" column="{goodId = id}" ofType="com.hssx.pcbms.entity.GoodsNo">-->
+        <!--</collection>-->
+        <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" />
+        </collection>
+    </resultMap>
+
+    <select id="getListBycondition" resultMap="BaseResultMapVO">
+        select
+        g.id, g.name, g.tag_id, g.model_number, g.unit,gn.id nid,
+        gn.model_no, gn.division_code, gn.suffix_code, gn.state, gn.indate, gn.goods_id, gn.user_id
+        from
+            goods g
+        left join
+            goods_no gn
+        on g.id = gn.goods_id
+        <where>
+            is_delete = 0
+            <if test="keyName != null and keyName != ''">
+                and name like concat('%',#{keyName},'%')
+            </if>
+            <if test="tagId != null">
+                and tag_id = #{tagId}
+            </if>
+        </where>
+    </select>
+    <select id="getDetail" resultMap="BaseResultMapVO">
+        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
+        from
+            goods g
+        left join
+            goods_no gn
+        on g.id = gn.goods_id
+        <where>
+            g.id = #{id}
+        </where>
+    </select>
 </mapper>