Commit 11d0ac9f authored by wanghao's avatar wanghao

1 液化石油气监管-车辆信息导入-功能开发

parent 143e9a2d
...@@ -5,12 +5,16 @@ import com.zehong.common.core.controller.BaseController; ...@@ -5,12 +5,16 @@ import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult; import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo; import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType; import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.SecurityUtils;
import com.zehong.common.utils.poi.ExcelUtil; import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.TLpgVehicleInfo; import com.zehong.system.domain.TLpgVehicleInfo;
import com.zehong.system.service.ITLpgVehicleInfoService; import com.zehong.system.service.ITLpgVehicleInfoService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List; import java.util.List;
/** /**
...@@ -87,4 +91,33 @@ public class TLpgVehicleInfoController extends BaseController ...@@ -87,4 +91,33 @@ public class TLpgVehicleInfoController extends BaseController
{ {
return toAjax(tLpgVehicleInfoService.deleteTLpgVehicleInfoByIds(vehicleIds)); return toAjax(tLpgVehicleInfoService.deleteTLpgVehicleInfoByIds(vehicleIds));
} }
/**
* 模版下载
* @return r
*/
@GetMapping("/importTemplate")
public AjaxResult importTemplate(){
ExcelUtil<TLpgVehicleInfo> util = new ExcelUtil<>(TLpgVehicleInfo.class);
return util.importTemplateExcel("车辆信息数据");
}
/**
* 文件导入
* @param file f
* @param updateSupport u
* @return r
* @throws Exception r
*/
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file, boolean updateSupport, HttpServletResponse response) throws Exception
{
ExcelUtil<TLpgVehicleInfo> util = new ExcelUtil<>(TLpgVehicleInfo.class);
List<TLpgVehicleInfo> XmbhList = util.importExcel(file.getInputStream());
tLpgVehicleInfoService.importLpgSafeCheckRecordInfo(XmbhList, updateSupport, response);
return AjaxResult.success();
}
} }
...@@ -43,7 +43,7 @@ public class TLpgVehicleInfo extends BaseEntity ...@@ -43,7 +43,7 @@ public class TLpgVehicleInfo extends BaseEntity
private String brandModel; private String brandModel;
/** 车辆类型: 1.罐车 2.卡车 */ /** 车辆类型: 1.罐车 2.卡车 */
@Excel(name = "车辆类型",readConverterExp = "1=罐车,2=卡车") @Excel(name = "车辆类型,1-罐车,2-卡车")
private String vehicleType; private String vehicleType;
/** 车辆载重 */ /** 车辆载重 */
...@@ -67,7 +67,7 @@ public class TLpgVehicleInfo extends BaseEntity ...@@ -67,7 +67,7 @@ public class TLpgVehicleInfo extends BaseEntity
private String personLiable; private String personLiable;
/** 使用状态 0未使用 1使用中 */ /** 使用状态 0未使用 1使用中 */
@Excel(name = "使用状态",readConverterExp = "0=未使用,1=使用中") @Excel(name = "使用状态,0-未使用,1-使用中")
private String onState; private String onState;
/** 使用人 */ /** 使用人 */
......
package com.zehong.system.mapper; package com.zehong.system.mapper;
import java.util.List; import java.util.List;
import com.zehong.system.domain.TLpgVehicleInfo; import com.zehong.system.domain.TLpgVehicleInfo;
import org.apache.ibatis.annotations.Param;
/** /**
* 液化石油车辆信息Mapper接口 * 液化石油车辆信息Mapper接口
...@@ -51,6 +53,12 @@ public interface TLpgVehicleInfoMapper ...@@ -51,6 +53,12 @@ public interface TLpgVehicleInfoMapper
*/ */
public int deleteTLpgVehicleInfoById(Long vehicleId); public int deleteTLpgVehicleInfoById(Long vehicleId);
/**
* 批量增加
* @param list list
* @return r
*/
public int insertBatch(@Param("list") List<TLpgVehicleInfo> list);
/** /**
* 批量删除液化石油车辆信息 * 批量删除液化石油车辆信息
* *
......
package com.zehong.system.service; package com.zehong.system.service;
import java.util.HashMap;
import java.util.List; import java.util.List;
import com.zehong.system.domain.TLpgVehicleInfo; import com.zehong.system.domain.TLpgVehicleInfo;
import com.zehong.system.domain.vo.TLpgSafeCheckRecordImportVo;
import javax.servlet.http.HttpServletResponse;
/** /**
* 液化石油车辆信息Service接口 * 液化石油车辆信息Service接口
...@@ -58,4 +62,12 @@ public interface ITLpgVehicleInfoService ...@@ -58,4 +62,12 @@ public interface ITLpgVehicleInfoService
* @return 结果 * @return 结果
*/ */
public int deleteTLpgVehicleInfoById(Long vehicleId); public int deleteTLpgVehicleInfoById(Long vehicleId);
/**
* 导入
* @param XmbhList data
* @param updateSupport 是否更新
* @param response res
* @return r
*/
public void importLpgSafeCheckRecordInfo(List<TLpgVehicleInfo> XmbhList, boolean updateSupport, HttpServletResponse response);
} }
package com.zehong.system.service.impl; package com.zehong.system.service.impl;
import java.util.HashMap;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -7,6 +8,8 @@ import com.zehong.system.mapper.TLpgVehicleInfoMapper; ...@@ -7,6 +8,8 @@ import com.zehong.system.mapper.TLpgVehicleInfoMapper;
import com.zehong.system.domain.TLpgVehicleInfo; import com.zehong.system.domain.TLpgVehicleInfo;
import com.zehong.system.service.ITLpgVehicleInfoService; import com.zehong.system.service.ITLpgVehicleInfoService;
import javax.servlet.http.HttpServletResponse;
/** /**
* 液化石油车辆信息Service业务层处理 * 液化石油车辆信息Service业务层处理
* *
...@@ -90,4 +93,19 @@ public class TLpgVehicleInfoServiceImpl implements ITLpgVehicleInfoService ...@@ -90,4 +93,19 @@ public class TLpgVehicleInfoServiceImpl implements ITLpgVehicleInfoService
{ {
return tLpgVehicleInfoMapper.deleteTLpgVehicleInfoById(vehicleId); return tLpgVehicleInfoMapper.deleteTLpgVehicleInfoById(vehicleId);
} }
/**
* 导入
* @param XmbhList data
* @param updateSupport 是否更新
* @param response res
* @return r
*/
@Override
public void importLpgSafeCheckRecordInfo(List<TLpgVehicleInfo> XmbhList, boolean updateSupport, HttpServletResponse response) {
if(XmbhList.size() > 0) {
tLpgVehicleInfoMapper.insertBatch(XmbhList);
}
}
} }
...@@ -56,7 +56,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -56,7 +56,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectTLpgVehicleInfoVo"/> <include refid="selectTLpgVehicleInfoVo"/>
where vehicle_id = #{vehicleId} where vehicle_id = #{vehicleId}
</select> </select>
<insert id="insertBatch" parameterType="list">
insert into t_lpg_vehicle_info (station_name, car_number,vehicle_code,car_num,brand_model,vehicle_type,
vehicle_load,vehicle_size,vehicle_limt,vehicle_inspect,person_liable,on_state,vehicle_user,
phone,remarks)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.stationName,jdbcType=VARCHAR}, #{item.carNumber}, #{item.vehicleCode,jdbcType=VARCHAR},
#{item.carNum,jdbcType=VARCHAR}, #{item.brandModel,jdbcType=VARCHAR}, #{item.vehicleType},
#{item.vehicleLoad},#{item.vehicleSize},#{item.vehicleLimt},#{item.vehicleInspect},
#{item.personLiable},#{item.onState},#{item.vehicleUser},#{item.phone},#{item.remarks})
</foreach>
</insert>
<insert id="insertTLpgVehicleInfo" parameterType="TLpgVehicleInfo" useGeneratedKeys="true" keyProperty="vehicleId"> <insert id="insertTLpgVehicleInfo" parameterType="TLpgVehicleInfo" useGeneratedKeys="true" keyProperty="vehicleId">
insert into t_lpg_vehicle_info insert into t_lpg_vehicle_info
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
...@@ -127,6 +141,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -127,6 +141,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
delete from t_lpg_vehicle_info where vehicle_id = #{vehicleId} delete from t_lpg_vehicle_info where vehicle_id = #{vehicleId}
</delete> </delete>
<delete id="deleteTLpgVehicleInfoByIds" parameterType="String"> <delete id="deleteTLpgVehicleInfoByIds" parameterType="String">
delete from t_lpg_vehicle_info where vehicle_id in delete from t_lpg_vehicle_info where vehicle_id in
<foreach item="vehicleId" collection="array" open="(" separator="," close=")"> <foreach item="vehicleId" collection="array" open="(" separator="," close=")">
......
...@@ -106,7 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -106,7 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="countByBeyondEnterpriseId" parameterType="String" resultType="int"> <select id="countByBeyondEnterpriseId" parameterType="String" resultType="int">
select count(*) from t_yehuaqi_user where error_msg is not null select count(*) from t_yehuaqi_user where error_msg is not null
<if test="beyondEnterpriseId != null and beyondEnterpriseId != '' and beyondEnterpriseId != '-2'"> <if test="beyondEnterpriseId != null and beyondEnterpriseId != '' and beyondEnterpriseId != '-2'">
beyond_enterprise_id = #{beyondEnterpriseId} and beyond_enterprise_id = #{beyondEnterpriseId}
</if> </if>
</select> </select>
...@@ -162,17 +162,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -162,17 +162,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<insert id="insertBatch" parameterType="list" useGeneratedKeys="true" keyProperty="userId"> <insert id="insertBatch" parameterType="list" useGeneratedKeys="true" keyProperty="userId">
insert into t_yehuaqi_user (nick_name, beyond_enterprise_name,beyond_enterprise_id, user_type, village_name,f_village_id, insert into t_yehuaqi_user (nick_name, beyond_enterprise_name,beyond_enterprise_id, user_type, village_name,f_village_id,
address, linkman, phone, remarks, error_msg) address, linkman, phone, remarks, error_msg,user_own_id)
values values
<foreach collection="list" item="item" index="index" separator=","> <foreach collection="list" item="item" index="index" separator=",">
( (
#{item.nickName,jdbcType=VARCHAR}, #{item.beyondEnterpriseName,jdbcType=VARCHAR}, #{item.beyondEnterpriseId,jdbcType=VARCHAR}, #{item.nickName,jdbcType=VARCHAR}, #{item.beyondEnterpriseName,jdbcType=VARCHAR}, #{item.beyondEnterpriseId,jdbcType=VARCHAR},
#{item.userType,jdbcType=VARCHAR}, #{item.villageName,jdbcType=VARCHAR}, #{item.userType,jdbcType=VARCHAR}, #{item.villageName,jdbcType=VARCHAR},#{item.villageId,jdbcType=DECIMAL},
#{item.villageId,jdbcType=DECIMAL},
#{item.address,jdbcType=VARCHAR}, #{item.linkman,jdbcType=VARCHAR}, #{item.phone,jdbcType=VARCHAR}, #{item.address,jdbcType=VARCHAR}, #{item.linkman,jdbcType=VARCHAR}, #{item.phone,jdbcType=VARCHAR},
#{item.remarks,jdbcType=VARCHAR}, #{item.errorMsg,jdbcType=VARCHAR} #{item.remarks,jdbcType=VARCHAR}, #{item.errorMsg,jdbcType=VARCHAR}, #{item.userOwnId,jdbcType=VARCHAR}
) )
</foreach> </foreach>
</insert> </insert>
......
...@@ -51,3 +51,11 @@ export function exportInfo(query) { ...@@ -51,3 +51,11 @@ export function exportInfo(query) {
params: query params: query
}) })
} }
// 下载用户导入模板
export function importTemplate() {
return request({
url: '/lpg/vehicleInfo/importTemplate',
method: 'get'
})
}
\ No newline at end of file
...@@ -396,7 +396,7 @@ export default { ...@@ -396,7 +396,7 @@ export default {
}, },
handleImport(){ handleImport(){
this.upload.title = "配送记录导入"; // todo this.upload.title = "安检记录导入"; // todo
this.upload.open = true; this.upload.open = true;
}, },
// 文件上传处理中 // 文件上传处理中
......
...@@ -74,6 +74,15 @@ ...@@ -74,6 +74,15 @@
@click="handleExport" @click="handleExport"
>导出</el-button> >导出</el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button
type="info"
icon="el-icon-upload2"
size="mini"
@click="handleImport">导入</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
...@@ -204,12 +213,43 @@ ...@@ -204,12 +213,43 @@
<!-- 详情 --> <!-- 详情 -->
<DetailInfo ref="detail"/> <DetailInfo ref="detail"/>
<!-- 用户导入对话框 -->
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload
ref="upload"
:limit="1"
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<span>仅允许导入xls、xlsx格式文件。</span>
<el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
<br>
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm">确 定</el-button>
<el-button @click="upload.open = false">取 消</el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { listInfo, getInfo, delInfo, addInfo, updateInfo, exportInfo } from "@/api/lpgRegulation/vehicleinfo"; import { listInfo, getInfo, delInfo, addInfo, updateInfo, exportInfo,importTemplate } from "@/api/lpgRegulation/vehicleinfo";
import DetailInfo from "./components/DetailInfo"; import DetailInfo from "./components/DetailInfo";
import { getToken } from "@/utils/auth";
export default { export default {
name: "Info", name: "Info",
components: { components: {
...@@ -217,6 +257,22 @@ export default { ...@@ -217,6 +257,22 @@ export default {
}, },
data() { data() {
return { return {
upload: {
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: "",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/lpg/vehicleInfo/importData"
},
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 导出遮罩层 // 导出遮罩层
...@@ -256,6 +312,39 @@ export default { ...@@ -256,6 +312,39 @@ export default {
this.getList(); this.getList();
}, },
methods: { methods: {
/** 下载模板操作 */
importTemplate() {
importTemplate().then(response => {
this.download(response.msg);
});
},
handleImport(){
this.upload.title = "车辆信息导入"; // todo
this.upload.open = true;
},
// 文件上传处理中
handleFileUploadProgress(event,file,fileList) {
this.upload.isUploading = true;
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
this.upload.open = false;
this.upload.isUploading = false;
this.$refs.upload.clearFiles();
this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
this.getList();
},
// 提交上传文件
submitFileForm() {
this.$refs.upload.submit();
},
/** 查询液化石油车辆信息列表 */ /** 查询液化石油车辆信息列表 */
getList() { getList() {
this.loading = true; this.loading = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment