Browse Source

产品树 添加 单机信息

wanggaokun 1 year ago
parent
commit
1e989325fc

+ 15 - 0
PHM-admin/phm-manage/src/main/java/com/phm/manage/controller/AircraftController.java

@@ -8,8 +8,10 @@ import com.phm.common.enums.BusinessType;
 import com.phm.common.utils.poi.ExcelUtil;
 import com.phm.manage.domain.Aircraft;
 import com.phm.manage.domain.Fleet;
+import com.phm.manage.domain.Product;
 import com.phm.manage.service.IAircraftService;
 import com.phm.manage.service.IFleetService;
+import com.phm.manage.service.IProductService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -32,6 +34,9 @@ public class AircraftController extends BaseController {
     @Autowired
     private IFleetService fleetService;
 
+    @Autowired
+    private IProductService productService;
+
     /**
      * 查询单机信息列表
      */
@@ -102,4 +107,14 @@ public class AircraftController extends BaseController {
     public AjaxResult fleetList(Fleet fleet) {
         return success(fleetService.selectFleetList(fleet));
     }
+
+    /**
+     * 获取机型信息列表
+     */
+    @PreAuthorize("@ss.hasPermi('manage:aircraft:list')")
+    @GetMapping("/productList")
+    public AjaxResult productList(Product product) {
+        product.setParentId(0L);
+        return success(productService.selectProductList(product));
+    }
 }

+ 14 - 0
PHM-admin/phm-manage/src/main/java/com/phm/manage/domain/Aircraft.java

@@ -31,6 +31,12 @@ public class Aircraft extends BaseEntity {
     @Excel(name = "机号")
     private String number;
 
+
+    /**
+     * 归属机型
+     */
+    private Long aircraftTypeId;
+
     /**
      * 归属机队
      */
@@ -66,6 +72,14 @@ public class Aircraft extends BaseEntity {
         return number;
     }
 
+    public Long getAircraftTypeId() {
+        return aircraftTypeId;
+    }
+
+    public void setAircraftTypeId(Long aircraftTypeId) {
+        this.aircraftTypeId = aircraftTypeId;
+    }
+
     public void setFleetId(String fleetId) {
         this.fleetId = fleetId;
     }

+ 6 - 1
PHM-admin/phm-manage/src/main/resources/mapper/manage/AircraftMapper.xml

@@ -9,6 +9,7 @@
         <result property="name"    column="name"    />
         <result property="number"    column="number"    />
         <result property="fleetId"    column="fleet_id"    />
+        <result property="aircraftTypeId"    column="aircraft_type_id"    />
         <result property="isDelete"    column="is_delete"    />
         <result property="createBy"    column="create_by"    />
         <result property="createTime"    column="create_time"    />
@@ -17,7 +18,7 @@
     </resultMap>
 
     <sql id="selectAircraftVo">
-        select id, name, number, fleet_id, is_delete, create_by, create_time, update_by, update_time from phm_aircraft
+        select id, name, number, fleet_id, aircraft_type_id, is_delete, create_by, create_time, update_by, update_time from phm_aircraft
     </sql>
 
     <select id="selectAircraftList" parameterType="Aircraft" resultMap="AircraftResult">
@@ -26,6 +27,7 @@
             <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
             <if test="number != null  and number != ''"> and number like concat('%', #{number}, '%')</if>
             <if test="fleetId != null  and fleetId != ''"> and fleet_id = #{fleetId}</if>
+            <if test="aircraftTypeId != null  and aircraftTypeId != ''"> and aircraft_type_id = #{aircraftTypeId}</if>
         </where>
     </select>
 
@@ -40,6 +42,7 @@
             <if test="name != null">name,</if>
             <if test="number != null">number,</if>
             <if test="fleetId != null">fleet_id,</if>
+            <if test="aircraftTypeId != null">aircraft_type_id,</if>
             <if test="isDelete != null">is_delete,</if>
             <if test="createBy != null">create_by,</if>
             <if test="createTime != null">create_time,</if>
@@ -50,6 +53,7 @@
             <if test="name != null">#{name},</if>
             <if test="number != null">#{number},</if>
             <if test="fleetId != null">#{fleetId},</if>
+            <if test="aircraftTypeId != null">#{aircraftTypeId},</if>
             <if test="isDelete != null">#{isDelete},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="createTime != null">#{createTime},</if>
@@ -64,6 +68,7 @@
             <if test="name != null">name = #{name},</if>
             <if test="number != null">number = #{number},</if>
             <if test="fleetId != null">fleet_id = #{fleetId},</if>
+            <if test="aircraftTypeId != null">aircraft_type_id = #{aircraftTypeId},</if>
             <if test="isDelete != null">is_delete = #{isDelete},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="createTime != null">create_time = #{createTime},</if>

+ 6 - 6
PHM-admin/phm-manage/src/main/resources/mapper/manage/ProductMapper.xml

@@ -23,11 +23,12 @@
         select t.id,
                t.parent_id,
                t.aircraft_id,
-               (CASE
-                    when t.parent_id = 0 THEN
-                        t2.`name`
-                    ELSE p2.`name`
-                   END) parent_name,
+<!--               (CASE-->
+<!--                    when t.parent_id = 0 THEN-->
+<!--                        t2.`name`-->
+<!--                    ELSE p2.`name`-->
+<!--                   END) parent_name,-->
+               p2.name as parent_name,
                t.ancestors,
                t.name,
                t.sns_id,
@@ -39,7 +40,6 @@
         FROM phm_product t
                  LEFT JOIN phm_product p2
                            ON t.parent_id = p2.id
-                 LEFT JOIN phm_aircraft t2 ON t.aircraft_id = t2.id
     </sql>
 
     <select id="selectProductList" parameterType="Product" resultMap="ProductResult">