há 5 anos atrás
pai
commit
655e547cf1

+ 16 - 0
pcbms/src/main/java/com/hssx/pcbms/entity/vo/GoodsDTO.java

@@ -0,0 +1,16 @@
+package com.hssx.pcbms.entity.vo;
+
+import com.hssx.pcbms.entity.Goods;
+import com.hssx.pcbms.entity.GoodsNo;
+import lombok.Data;
+
+/**
+ * Author: 吴涛涛 cuiyi@itany.com
+ * Date : 2019 - 11 - 18 17:31
+ * Description:<描述>
+ * Version: 1.0
+ */
+@Data
+public class GoodsDTO extends Goods {
+    private GoodsNo goodsNo;
+}

+ 4 - 1
pcbms/src/main/java/com/hssx/pcbms/mapper/GoodsMapper.java

@@ -2,6 +2,7 @@ package com.hssx.pcbms.mapper;
 
 import com.hssx.pcbms.entity.Goods;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.hssx.pcbms.entity.vo.GoodsDTO;
 import com.hssx.pcbms.entity.vo.GoodsVO;
 import org.apache.ibatis.annotations.Param;
 
@@ -19,5 +20,7 @@ public interface GoodsMapper extends BaseMapper<Goods> {
 
     List<GoodsVO> selectMyList(@Param("start")Integer start, @Param("pageSize")Integer pageSize, @Param("uid")Integer uid);
 
-    List<GoodsVO> getRackListBycondition(@Param("keyName") String keyName, @Param("tagId") Integer tagId,@Param("uid")Integer uid);
+    List<GoodsVO> getRackListBycondition(@Param("keyName") String keyName, @Param("tagId") Integer tagId,@Param("uid")Integer uid,@Param("goodType")Integer goodType);
+
+    List<GoodsVO> getEuipmentList(@Param("ids")List<Integer> equipmentIds);
 }

+ 43 - 13
pcbms/src/main/java/com/hssx/pcbms/service/impl/GoodsServiceImpl.java

@@ -5,10 +5,7 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.hssx.pcbms.constant.Constant;
 import com.hssx.pcbms.entity.*;
-import com.hssx.pcbms.entity.vo.GoodsNoVO;
-import com.hssx.pcbms.entity.vo.GoodsVO;
-import com.hssx.pcbms.entity.vo.MaintainRecordVO;
-import com.hssx.pcbms.entity.vo.OperateRecordVO;
+import com.hssx.pcbms.entity.vo.*;
 import com.hssx.pcbms.mapper.*;
 import com.hssx.pcbms.service.GoodsNoService;
 import com.hssx.pcbms.service.GoodsService;
@@ -21,15 +18,15 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.multipart.MultipartFile;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -66,6 +63,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     private NewsNoticeMapper newsNoticeMapper;
     @Resource
     private NewsNoticeUserMapper newsNoticeUserMapper;
+    @Resource
+    private RacksEquipmentMapper racksEquipmentMapper;
 
     @Override
     public HttpRespMsg add(GoodsVO goodsVO) {
@@ -108,6 +107,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
 
     @Override
     public HttpRespMsg getList(PageUtil page, String keyName, Integer tagId, Integer uid) {
+        System.out.println(tagId);
         HttpRespMsg msg = new HttpRespMsg();
         PageHelper.startPage(page.getPageNum(), page.getPageSize());
         List<GoodsVO> list = new ArrayList<>();
@@ -137,9 +137,23 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
 //                return msg;
 //            }
 //        }else{
+        Integer goodType = 0;
+        if(tagId !=null){
+            if(tagId==-1){
+                goodType = 1;
+            }else if(tagId==-2){
+                goodType = 2;
+            }
+        }
+        if(goodType==0){
             list = goodsMapper.getListBycondition(keyName, tagId, uid);
             PageInfo<GoodsVO> info = new PageInfo<>(list);
             msg.data = info;
+        }else{
+            list = goodsMapper.getRackListBycondition(keyName, tagId, uid,goodType);
+            PageInfo<GoodsVO> info = new PageInfo<>(list);
+            msg.data = info;
+        }
 //        }
         return msg;
     }
@@ -167,9 +181,23 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     @Override
     public HttpRespMsg getDetail(Integer id) {
         HttpRespMsg msg = new HttpRespMsg();
-        GoodsVO vo = goodsMapper.getDetail(id);
-        msg.data = vo;
-        return msg;
+        Goods goods = goodsMapper.selectById(id);
+        Map<String,Object> map = new HashMap<>();
+        if(goods.getGoodType()!=0){
+            List<Integer> equipmentIds = racksEquipmentMapper.selectList(new QueryWrapper<RacksEquipment>().eq("rack_goods_id", id)).stream().map(RacksEquipment::getEquipmentGoodsId).collect(Collectors.toList());
+            if(equipmentIds.size()>0){
+                List<GoodsVO> list = goodsMapper.getEuipmentList(equipmentIds);
+                GoodsVO vo = goodsMapper.getDetail(id);
+                map.put("rack",vo);
+                map.put("equipments",list);
+            }
+            msg.data = map;
+            return msg;
+        }else{
+            GoodsVO vo = goodsMapper.getDetail(id);
+            msg.data = vo;
+            return msg;
+        }
     }
 
     @Override
@@ -509,8 +537,10 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     public static void main(String[] args) {
 //        String format = String.format("%04d", 0);
 //        System.out.println(format);
-        System.out.println("QWE-ASDF0001".substring(0, "QWE-ASDF0001".length() - 4));
-        System.out.println("QWE-ASDF0001".substring("QWE-ASDF0001".length() - 4));
-        System.out.println(Integer.parseInt("0001"));
+//        System.out.println("QWE-ASDF0001".substring(0, "QWE-ASDF0001".length() - 4));
+//        System.out.println("QWE-ASDF0001".substring("QWE-ASDF0001".length() - 4));
+//        System.out.println(Integer.parseInt("0001"));
+        List<Integer> list = new ArrayList<>();
+        System.out.println(list.stream().map(a ->a).collect(Collectors.toList()));
     }
 }

+ 67 - 16
pcbms/src/main/resources/mapper/GoodsMapper.xml

@@ -96,16 +96,51 @@
         <result column="tag_name" property="tagName" />
         <collection property="goodsNosVO" ofType="com.hssx.pcbms.entity.vo.GoodsNoVO">
             <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="username" property="username"/>
+            <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="update_indate" property="updateIndate" />
             <result column="is_maintain" property="isMaintain" />
-            <result column="phone" property="phone" />
+            <result column="good_sn_no" property="goodSnNo" />
+            <result column="label_id" property="labelId" />
+            <result column="model_id" property="modelId" />
+            <result column="u_bit_num" property="uBitNum" />
+            <result column="power" property="power" />
+            <result column="rated_current" property="ratedCurrent" />
+            <result column="rated_voltage" property="ratedVoltage" />
+            <result column="serial_number" property="serialNumber" />
+            <result column="affiliate" property="affiliate" />
+            <result column="device_category" property="deviceCategory" />
+            <result column="stock" property="stock" />
+            <result column="server_weight" property="serverWeight" />
+            <result column="manufacturer" property="manufacturer" />
+            <result column="supplier" property="supplier" />
+            <result column="charger_id" property="chargerId" />
+            <result column="charger_name" property="chargerName" />
+            <result column="maintain_clc" property="maintainClc" />
+            <result column="maintenance_phone" property="maintenancePhone" />
+            <result column="last_maintainer_id" property="lastMaintainerId" />
+            <result column="last_maintainer_name" property="lastMaintainerName" />
+            <result column="next_maintainer_id" property="nextMaintainerId" />
+            <result column="next_maintainer_name" property="nextMaintainerName" />
+            <result column="last_update_time" property="lastUpdateTime" />
+            <result column="next_update_time" property="nextUpdateTime" />
+            <result column="grounding_time" property="groundingTime" />
+            <result column="undercarriage_time" property="undercarriageTime" />
+            <result column="first_use_time" property="firstUseTime" />
+            <result column="current_state" property="currentState" />
+            <result column="alarm_level" property="alarmLevel" />
+            <result column="subordinate_user_id" property="subordinateUserId" />
+            <result column="subordinate_user" property="subordinateUser" />
+            <result column="floor" property="floor" />
+            <result column="room" property="room" />
+            <result column="column_place" property="columnPlace" />
+            <result column="region" property="region" />
+            <result column="is_rack" property="isRack" />
         </collection>
     </resultMap>
     <select id="getListBycondition" resultMap="BaseResultMapVO">
@@ -122,9 +157,6 @@
             <if test="tagId != null">
                 and tag_id = #{tagId}
             </if>
-            <if test="tagId == null">
-                and tag_id &lt;&gt; -1 and tag_id &lt;&gt; -2
-            </if>
         </where>
         order by id desc
     </select>
@@ -158,6 +190,28 @@
             g.id = #{id}
         </where>
     </select>
+    <select id="getEuipmentList" resultMap="BaseResultMapDetail">
+        select
+        g.id, g.name, g.tag_id,gt.name tag_name, g.model_number, g.unit,g.address, g.factory, g.pic, g.service_life, g.next_indate,g.division_code divisioncode,g.suffix_code suffixcode,
+        g.is_delete,gn.id nid,g.good_type,rd.hum,rd.door_status,rd.temp,gn.is_rack,
+        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
+        left join rack_data rd
+        on g.id = rd.goods_id
+        left join goods_tags gt
+        on gt.id = g.tag_id
+        <where>
+            g.id in <foreach collection="ids" index="index" open="(" item="item" close=")" separator=",">
+            #{item}
+        </foreach>
+        </where>
+    </select>
 
     <select id="selectMyList" resultMap="BaseResultMapMyList">
         select
@@ -192,16 +246,13 @@
         left join rack_data rd
         on g.id = rd.goods_id
         <where>
-            is_delete = 0
+            is_delete = 0 and good_type = #{goodType}
             <if test="keyName != null and keyName != ''">
                 and g.name like concat('%',#{keyName},'%')
             </if>
             <if test="tagId != null">
                 and g.tag_id = #{tagId}
             </if>
-            <if test="tagId == null">
-                and g.tag_id &lt;&gt; -1 and g.tag_id &lt;&gt; -2
-            </if>
         </where>
         order by g.indate desc
     </select>