Commit df6ecdfc authored by wanghao's avatar wanghao

1 用户管理-燃气用户界面 导出,使用 模版填充格式实现。

2 用户管理-燃气用户界面 导出 时增加全局遮罩。
parent 2abf4f95
......@@ -2,6 +2,7 @@ package com.zehong.web.controller.supervise;
import java.io.*;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
......@@ -303,6 +304,77 @@ public class TDetectorUserController extends BaseController
return AjaxResult.success(message);
}
/**
* 自定义-模版下载-正确数据导出
* @param response r
* @param tDetectorUser t
*/
@GetMapping("/exportSuccessData")
public void exportSuccessData(HttpServletResponse response,TDetectorUser tDetectorUser) {
//获取用户信息
SysUser user = SecurityUtils.getLoginUser().getUser();
tDetectorUser.setBeyondEnterpriseId(user.getDeptId());
List<TDetectorUser> tDetectorUsers = tDetectorUserService.selectForExportTDetectorUserList(tDetectorUser);
//判断是否是 windows环境,
String osName = System.getProperty("os.name").toLowerCase();
try {
File file;
//如果是本地或测试环境
if (osName.contains("windows")) {
String filePath = "importTemplate/燃气用户导出模版.xlsx";
//用来读取resources下的文件
Resource resource = new ClassPathResource(filePath);
file = resource.getFile();
} else {
file = ResourceUtils.getFile("/data/java/baseversion/importTemplate/燃气用户导出模版.xlsx");
}
List<UserManageSafetyDeviceExportVo> userManageSafetyDeviceExportVoList = new ArrayList<>();
for (TDetectorUser tDetectorUserDb : tDetectorUsers) {
List<UserManageSafetyDeviceExportVo> userManageSafetyDeviceExportVos = tDetectorUserDb.getUserManageSafetyDeviceExportVos();
if (userManageSafetyDeviceExportVos != null && userManageSafetyDeviceExportVos.size() > 0) {
userManageSafetyDeviceExportVoList.addAll(userManageSafetyDeviceExportVos);
}
}
TemplateExportParams params = new TemplateExportParams(file.getAbsolutePath(), true);
Map<String, Object> total = new HashMap<>();
total.put("gasUserMaplist",tDetectorUsers);
if(userManageSafetyDeviceExportVoList.size() > 0) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (UserManageSafetyDeviceExportVo userManageSafetyDeviceExportVo : userManageSafetyDeviceExportVoList) {
if (userManageSafetyDeviceExportVo.getDeviceInstallTime() != null) {
String format = sdf.format(userManageSafetyDeviceExportVo.getDeviceInstallTime());
userManageSafetyDeviceExportVo.setDeviceInstallTimeStr(format);
}
}
}
total.put("safetyDeviceMaplist",userManageSafetyDeviceExportVoList);
Workbook workbook = ExcelExportUtil.exportExcel(params, total);
String fileName = "燃气用户数据.xlsx";
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
OutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);
outputStream.flush();
outputStream.close();
workbook.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
/**
* 自定义-模版下载-带有错误数据
* @param response r
......@@ -388,8 +460,6 @@ public class TDetectorUserController extends BaseController
// 获取文件名
String filename = file.getName();
// 获取文件后缀名
String ext = filename.substring(filename.lastIndexOf(".") + 1).toLowerCase();
// 将文件写入输入流
FileInputStream fileInputStream = new FileInputStream(file);
......
......@@ -5,6 +5,7 @@ import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zehong.system.domain.vo.UserManageSafetyDeviceExportVo;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zehong.common.annotation.Excel;
......@@ -121,6 +122,10 @@ public class TDetectorUser extends BaseEntity
private List<Long> hasInspectUser;
/**
* 安全装置集合 导出时使用
*/
private List<UserManageSafetyDeviceExportVo> userManageSafetyDeviceExportVos;
public String getBeyondEnterpriseName() {
return beyondEnterpriseName;
......@@ -339,6 +344,14 @@ public class TDetectorUser extends BaseEntity
this.errorMsg = errorMsg;
}
public List<UserManageSafetyDeviceExportVo> getUserManageSafetyDeviceExportVos() {
return userManageSafetyDeviceExportVos;
}
public void setUserManageSafetyDeviceExportVos(List<UserManageSafetyDeviceExportVo> userManageSafetyDeviceExportVos) {
this.userManageSafetyDeviceExportVos = userManageSafetyDeviceExportVos;
}
@Override
public String toString() {
return "TDetectorUser{" +
......
......@@ -33,9 +33,11 @@ public class UserManageSafetyDeviceExportVo {
/** 设备安装时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "设备安装时间(yyyy-mm-dd)", width = 30,format="yyyy-MM-dd")
@Excel(name = "设备安装时间(yyyy-mm-dd)",width = 30,format ="yyyy-MM-dd")
private Date deviceInstallTime;
private String deviceInstallTimeStr;
/** 安装位置 */
@Excel(name = "安装位置")
private String deviceInstallPosition;
......@@ -127,4 +129,12 @@ public class UserManageSafetyDeviceExportVo {
public void setPhone(String phone) {
this.phone = phone;
}
public String getDeviceInstallTimeStr() {
return deviceInstallTimeStr;
}
public void setDeviceInstallTimeStr(String deviceInstallTimeStr) {
this.deviceInstallTimeStr = deviceInstallTimeStr;
}
}
......@@ -61,6 +61,13 @@ public interface TDetectorUserMapper
* @return 燃气用户集合
*/
public List<TDetectorUser> selectTDetectorUserList(TDetectorUser tDetectorUser);
/**
* 查询燃气用户列表 - 导出使用
*
* @param tDetectorUser 燃气用户
* @return 燃气用户集合
*/
public List<TDetectorUser> selectForExportTDetectorUserList(TDetectorUser tDetectorUser);
/**
* 查询燃气用户列表-new 有 居住区了
......
......@@ -68,6 +68,13 @@ public interface TGasuserSafetyDeviceInfoMapper
*/
public int deleteTGasuserSafetyDeviceInfoById(Long gasUserSafetyDeviceId);
/**
* 根据 userid删除 数据
* @param userId user
* @return r
*/
public void deleteTGasuserSafetyDeviceInfoByUserId(Long userId);
/**
* 批量删除用户管理-燃气用户-安全装置加装维护
*
......
......@@ -99,6 +99,15 @@ public interface ITDetectorUserService
* @return 燃气用户集合
*/
public List<TDetectorUser> newSelectTDetectorUserList(TDetectorUser tDetectorUser);
/**
* 查询燃气用户列表 - 导出使用
* @param tDetectorUser t
* @return r
*/
public List<TDetectorUser> selectForExportTDetectorUserList(TDetectorUser tDetectorUser);
public List<TDetectorUser> selectTDetectorListstatus(TDetectorUser tDetectorUser);
/**
......
......@@ -304,6 +304,16 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService
return tDetectorUserMapper.newSelectTDetectorUserList(tDetectorUser);
}
/**
* 查询燃气用户列表 - 导出使用
* @param tDetectorUser t
* @return r
*/
@Override
public List<TDetectorUser> selectForExportTDetectorUserList(TDetectorUser tDetectorUser) {
return tDetectorUserMapper.selectForExportTDetectorUserList(tDetectorUser);
}
@Override
public List<TDetectorUser> selectTDetectorListstatus(TDetectorUser tDetectorUser){
return tDetectorUserMapper.selectTDetectorListstatus(tDetectorUser);
......@@ -335,8 +345,8 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService
for (TGasuserSafetyDeviceInfo tGasuserSafetyDeviceInfo : gasuserSafetyDeviceInfoList) {
tGasuserSafetyDeviceInfo.setRelationGasuserId(detectorUser.getUserId());
}
gasuserSafetyDeviceInfoMapper.updatetRelationSafetyDeviceInfo(gasuserSafetyDeviceInfoList, detectorUser.getUserId());
}
gasuserSafetyDeviceInfoMapper.insertBatch(gasuserSafetyDeviceInfoList);
return 1;
}
......@@ -346,15 +356,21 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService
* @return r
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int updateUserAndSafetyDevice(GasUserAndSafetyDeviceVo gasUserAndSafetyDeviceVo) {
TDetectorUser detectorUser = gasUserAndSafetyDeviceVo.getDetectorUser();
tDetectorUserMapper.updateTDetectorUser(detectorUser);
List<TGasuserSafetyDeviceInfo> gasuserSafetyDeviceInfoList = gasUserAndSafetyDeviceVo.getGasuserSafetyDeviceInfoList();
if (gasuserSafetyDeviceInfoList != null && gasuserSafetyDeviceInfoList.size() > 0) {
for (TGasuserSafetyDeviceInfo tGasuserSafetyDeviceInfo : gasuserSafetyDeviceInfoList) {
tGasuserSafetyDeviceInfo.setRelationGasuserId(detectorUser.getUserId());
}
gasuserSafetyDeviceInfoMapper.updatetRelationSafetyDeviceInfo(gasuserSafetyDeviceInfoList, detectorUser.getUserId());
}
gasuserSafetyDeviceInfoMapper.deleteTGasuserSafetyDeviceInfoByUserId(detectorUser.getUserId());
if (gasuserSafetyDeviceInfoList != null && gasuserSafetyDeviceInfoList.size() > 0) {
gasuserSafetyDeviceInfoMapper.insertBatch(gasuserSafetyDeviceInfoList);
}
return 1;
}
......
......@@ -21,12 +21,50 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
<result property="isDel" column="is_del" />
<result property="remarks" column="remarks" />
<result property="beyondEnterpriseName" column="beyond_enterprise_name" />
<result property="beyondEnterpriseName" column="enterprise_name" />
<result property="villageId" column="f_village_id" />
<result property="villageName" column="village_name" />
<result property="villageName" column="f_village_name" />
<result property="errorMsg" column="error_msg" />
</resultMap>
<resultMap type="TDetectorUser" id="TDetectorUserExportResult">
<result property="userId" column="user_id" />
<result property="username" column="username" />
<result property="nickName" column="nick_name" />
<result property="beyondEnterpriseId" column="beyond_enterprise_id" />
<result property="userType" column="user_type" />
<result property="gasType" column="gas_type" />
<result property="address" column="address" />
<result property="longitude" column="longitude" />
<result property="latitude" column="latitude" />
<result property="linkman" column="linkman" />
<result property="phone" column="phone" />
<result property="email" column="email" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="isDel" column="is_del" />
<result property="remarks" column="remarks" />
<result property="beyondEnterpriseName" column="enterprise_name" />
<result property="villageId" column="f_village_id" />
<result property="villageName" column="f_village_name" />
<result property="errorMsg" column="error_msg" />
<!-- collection 是用于建立一对多中集合属性的对应关系
ofType 用于指定集合元素的数据类型
-->
<collection property="userManageSafetyDeviceExportVos" ofType="UserManageSafetyDeviceExportVo">
<id property="userOwnId" column="user_id"/>
<result property="relationDeviceType" column="f_relation_device_type"/>
<result property="deviceName" column="f_device_name"/>
<result property="deviceModel" column="f_device_model"/>
<result property="fIotNo" column="f_iot_no"/>
<result property="detectionMedium" column="f_detection_medium"/>
<result property="deviceInstallTime" column="f_device_install_time"/>
<result property="deviceInstallPosition" column="f_device_install_position"/>
<result property="head" column="f_head"/>
<result property="phone" column="f_phone"/>
</collection>
</resultMap>
<resultMap type="TDetectorUserInspectVo" id="TDetectorUserInspectResult">
<result property="userId" column="user_id" />
<result property="nickName" column="nick_name" />
......@@ -54,6 +92,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</select>
<select id="selectForExportTDetectorUserList" parameterType="TDetectorUser" resultMap="TDetectorUserExportResult">
select a.user_id,
a.username,
a.nick_name,
(CASE a.user_type WHEN '1' THEN '居民用户' WHEN '2' THEN '商业用户'WHEN '3' THEN '工业用户'WHEN '4' THEN '餐饮单位用户'end) as user_type ,
(CASE a.gas_type WHEN '0' THEN '天然气' WHEN '1' THEN '液化气' end) as gas_type ,
a.address, a.longitude, a.latitude, a.linkman, a.phone, a.email, a.create_time, a.update_time, a.is_del, a.remarks,
b.enterprise_name,a.f_village_id,v.f_village_name,
deviceInfo.f_relation_device_type,
deviceInfo.f_device_name,
deviceInfo.f_device_model,
deviceInfo.f_iot_no,
deviceInfo.f_detection_medium,
deviceInfo.f_device_install_time,
deviceInfo.f_device_install_position,
deviceInfo.f_head,
deviceInfo.f_phone
from t_detector_user a left join t_enterprise_info b on a.beyond_enterprise_id=b.enterprise_id
left join t_user_manage_village v on a.f_village_id=v.f_village_id
left join t_gasuser_safety_device_info deviceInfo on a.user_id = deviceInfo.f_relation_gasUser_id
<where> a.is_del = '0' and a.error_msg is null
<if test="beyondEnterpriseId != null and beyondEnterpriseId != -2"> and a.beyond_enterprise_id =#{beyondEnterpriseId}</if>
<if test="username != null and username != ''"> and a.username like concat('%', #{username}, '%')</if>
<if test="nickName != null and nickName != ''"> and (a.nick_name like concat('%', #{nickName}, '%') or a.username like concat('%', #{nickName}, '%'))</if>
<if test="isInspect != null and isInspect == 0">
and a.user_id not in
<foreach item="hasInspectUser" collection="hasInspectUser" open="(" separator="," close=")">
#{hasInspectUser}
</foreach>
</if>
<if test="isInspect != null and isInspect == 1">
and a.user_id in
<foreach item="hasInspectUser" collection="hasInspectUser" open="(" separator="," close=")">
#{hasInspectUser}
</foreach>
</if>
</where>
order by a.user_id desc
</select>
<select id="selectTDetectorUserList" parameterType="TDetectorUser" resultMap="TDetectorUserResult">
select a.user_id,
a.username,
......
......@@ -130,6 +130,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<delete id="deleteTGasuserSafetyDeviceInfoById" parameterType="Long">
delete from t_gasuser_safety_device_info where f_gasUser_safety_device_id = #{gasUserSafetyDeviceId}
</delete>
<select id="deleteTGasuserSafetyDeviceInfoByUserId" parameterType="Long">
delete from t_gasuser_safety_device_info where f_relation_gasUser_id = #{userId}
</select>
<delete id="deleteTGasuserSafetyDeviceInfoByIds" parameterType="String">
delete from t_gasuser_safety_device_info where f_gasUser_safety_device_id in
......
......@@ -176,3 +176,13 @@ export function exportErrorData() {
responseType: 'blob'
})
}
//自定义-模版下载-正确数据导出-燃气用户
export function exportSuccessData(query) {
return request({
url: '/supervise/user/exportSuccessData',
method: 'get',
responseType: 'blob',
params: query
})
}
\ No newline at end of file
import Vue from 'vue'
import loading001 from './index.vue'
const LoadingConstructor = Vue.extend(loading001)
let loadingNum=0;
const instance = new LoadingConstructor({
el: document.createElement('div')
})
instance.show = false
const loading = {
show() {
instance.show = true
document.body.appendChild(instance.$el)
loadingNum++
},
hide() {
loadingNum--
if(loadingNum===0){
instance.show = false
}
}
}
export default {
install() {
if (!Vue.$showLoading) {
Vue.$showLoading = loading
}
Vue.mixin({
created() {
this.$showLoading = Vue.$showLoading
}
})
}
}
\ No newline at end of file
<template>
<div v-if="show">
<div class="loader-rainbow">
<div class="loader-inner">
<div class="loader-line-wrap">
<div class="loader-line"></div>
</div>
<div class="loader-line-wrap">
<div class="loader-line"></div>
</div>
<div class="loader-line-wrap">
<div class="loader-line"></div>
</div>
<div class="loader-line-wrap">
<div class="loader-line"></div>
</div>
<div class="loader-line-wrap">
<div class="loader-line"></div>
</div>
<div class="box10" style="margin-top: 120px">拼命加载中....</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: "loading",
props: {
show: Boolean,
},
data() {
return {};
},
};
</script>
<style scoped>
.loader-rainbow {
position: fixed;
top: 50%;
left: 50%;
width: 100%;
height: 100%;
transform: translate(-50%, -50%);
z-index: 9999;
background-color: rgba(0,0,0,.5);
}
.loader-inner {
bottom: 0;
height: 100px;
left: 0;
margin: auto;
position: absolute;
right: 0;
top: 0;
width: 150px;
}
.loader-line-wrap {
animation: spin 2000ms cubic-bezier(0.175, 0.885, 0.32, 1.275) infinite;
box-sizing: border-box;
height: 50px;
left: 0;
overflow: hidden;
position: absolute;
top: 0;
transform-origin: 50% 100%;
width: 100px;
}
.loader-line {
border: 4px solid transparent;
border-radius: 100%;
box-sizing: border-box;
height: 100px;
left: 0;
margin: 0 auto;
position: absolute;
right: 0;
top: 0;
width: 100px;
}
.loader-line-wrap:nth-child(1) {
animation-delay: -50ms;
}
.loader-line-wrap:nth-child(2) {
animation-delay: -100ms;
}
.loader-line-wrap:nth-child(3) {
animation-delay: -150ms;
}
.loader-line-wrap:nth-child(4) {
animation-delay: -200ms;
}
.loader-line-wrap:nth-child(5) {
animation-delay: -250ms;
}
.loader-line-wrap:nth-child(1) .loader-line {
border-color: hsl(0, 80%, 60%);
height: 90px;
width: 90px;
top: 7px;
}
.loader-line-wrap:nth-child(2) .loader-line {
border-color: hsl(60, 80%, 60%);
height: 76px;
width: 76px;
top: 14px;
}
.loader-line-wrap:nth-child(3) .loader-line {
border-color: hsl(120, 80%, 60%);
height: 62px;
width: 62px;
top: 21px;
}
.loader-line-wrap:nth-child(4) .loader-line {
border-color: hsl(180, 80%, 60%);
height: 48px;
width: 48px;
top: 28px;
}
.loader-line-wrap:nth-child(5) .loader-line {
border-color: hsl(240, 80%, 60%);
height: 34px;
width: 34px;
top: 35px;
}
@keyframes spin {
0%,
15% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}
.box10 {
background: linear-gradient(to bottom, rgb(107, 175, 240), rgb(245, 137, 227));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-weight: bold;
font-size: 20px;
}
</style>
\ No newline at end of file
......@@ -47,6 +47,9 @@ import 'video.js/dist/video-js.css'
//require('video.js/dist/video-js.css')
//require('vue-video-player/src/custom-theme.css')
import exportLoadong from "./components/loading/index";
Vue.use(exportLoadong)
Vue.use(VideoPlayer)
// 全局方法挂载
Vue.prototype.$echarts = echarts;
......
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