Commit 3d60b095 authored by 周昊's avatar 周昊
Browse files

1、楼宇添加地上地下楼层字段,批量导入楼层

parent 70fd1fae
Loading
Loading
Loading
Loading
+35 −0
Original line number Original line Diff line number Diff line
package com.censoft.censoftrongtong.controller;
package com.censoft.censoftrongtong.controller;


import java.util.List;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponse;


import com.censoft.censoftrongtong.domain.LedgerBuilding;
import com.censoft.censoftrongtong.domain.LedgerBuilding;
import com.censoft.censoftrongtong.domain.LedgerFloor;
import com.censoft.censoftrongtong.service.ILedgerBuildingService;
import com.censoft.censoftrongtong.service.ILedgerBuildingService;
import com.censoft.censoftrongtong.service.ILedgerFloorService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.GetMapping;
@@ -102,4 +105,36 @@ public class LedgerBuildingController extends BaseController
    {
    {
        return toAjax(ledgerBuildingService.deleteLedgerBuildingByIds(ids));
        return toAjax(ledgerBuildingService.deleteLedgerBuildingByIds(ids));
    }
    }


    @Resource
    private ILedgerFloorService ledgerFloorService;

    //批量导入
    @GetMapping("/insert/all")
    public void test(LedgerBuilding ledgerBuilding)
    {
        List<LedgerBuilding> list = ledgerBuildingService.selectLedgerBuildingList(ledgerBuilding);
        for (LedgerBuilding building : list) {
            if (building.getGroundFloor()!=0){
                for (int i = 1; i <= building.getGroundFloor(); i++) {
                    LedgerFloor ledgerFloor = new LedgerFloor();
                    ledgerFloor.setBuildingId(building.getId());
                    ledgerFloor.setName(i+"层");
                    ledgerFloor.setType("地上");
                    ledgerFloorService.insertLedgerFloor(ledgerFloor);
                }
            }
            if (building.getUndergroundFloor()!=0){
                for (int i = 1; i <= building.getUndergroundFloor(); i++) {
                    LedgerFloor ledgerFloor = new LedgerFloor();
                    ledgerFloor.setBuildingId(building.getId());
                    ledgerFloor.setName(-i+"层");
                    ledgerFloor.setType("地下");
                    ledgerFloorService.insertLedgerFloor(ledgerFloor);
                }
            }
        }
        return ;
    }
}
}
+8 −0
Original line number Original line Diff line number Diff line
@@ -44,6 +44,14 @@ public class LedgerBuilding extends BaseEntityClean
    @Excel(name = "楼层")
    @Excel(name = "楼层")
    private String floor;
    private String floor;


    /** 地上楼层 */
    @Excel(name = "地上楼层")
    private Integer groundFloor;

    /** 地下楼层 */
    @Excel(name = "地下楼层")
    private Integer undergroundFloor;

    /** 用途 */
    /** 用途 */
    @Excel(name = "用途")
    @Excel(name = "用途")
    private String useto;
    private String useto;
+3 −1
Original line number Original line Diff line number Diff line
@@ -11,6 +11,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        <result property="type"    column="type"    />
        <result property="type"    column="type"    />
        <result property="deptId"    column="dept_id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="floor"    column="floor"    />
        <result property="floor"    column="floor"    />
        <result property="groundFloor"    column="ground_floor"    />
        <result property="undergroundFloor"    column="underground_floor"    />
        <result property="useto"    column="useto"    />
        <result property="useto"    column="useto"    />
        <result property="city"    column="city"    />
        <result property="city"    column="city"    />
        <result property="area"    column="area"    />
        <result property="area"    column="area"    />
@@ -28,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    </sql>
    </sql>


    <select id="selectLedgerBuildingList" parameterType="com.censoft.censoftrongtong.domain.LedgerBuilding" resultMap="LedgerBuildingResult">
    <select id="selectLedgerBuildingList" parameterType="com.censoft.censoftrongtong.domain.LedgerBuilding" resultMap="LedgerBuildingResult">
        select * from (SELECT b.id, b.project_id, p.NAME 'project_name', b.NAME, b.type, b.dept_id, d.dept_name, b.floor, b.useto, b.city, b.area, b.address, b.STATUS, b.del_flag, b.create_by, b.create_time, b.update_by, b.update_time FROM ledger_building b LEFT JOIN sys_dept d ON b.dept_id = d.dept_id LEFT JOIN ledger_project p ON b.project_id = p.id) tt
        select * from (SELECT b.id, b.project_id, p.NAME 'project_name', b.NAME, b.type, b.dept_id, d.dept_name, b.floor,b.ground_floor,b.underground_floor, b.useto, b.city, b.area, b.address, b.STATUS, b.del_flag, b.create_by, b.create_time, b.update_by, b.update_time FROM ledger_building b LEFT JOIN sys_dept d ON b.dept_id = d.dept_id LEFT JOIN ledger_project p ON b.project_id = p.id) tt
        <where>  
        <where>  
            <if test="projectName != null "> and tt.project_name like concat('%', #{projectName}, '%') </if>
            <if test="projectName != null "> and tt.project_name like concat('%', #{projectName}, '%') </if>
            <if test="projectId != null "> and tt.project_id = #{projectId} </if>
            <if test="projectId != null "> and tt.project_id = #{projectId} </if>