Commit 90967c58 authored by wanghao's avatar wanghao

1 液化石油气监管-配送记录导入功能开发。

parent 17d7ee03
package com.zehong.web.controller.lpgRegulation;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import java.util.stream.Collectors;
import com.zehong.common.core.domain.entity.SysRole;
import com.zehong.common.utils.SecurityUtils;
import com.zehong.system.domain.vo.TLpgDeliveryRecordImportVo;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -19,6 +24,9 @@ import com.zehong.system.domain.TLpgDeliveryRecord;
import com.zehong.system.service.ITLpgDeliveryRecordService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
/**
* 液化石油配送记录Controller
......@@ -56,6 +64,52 @@ public class TLpgDeliveryRecordController extends BaseController
return util.exportExcel(list, "液化石油配送记录数据");
}
/**
* 模版下载
* @return r
*/
@GetMapping("/importTemplate")
public AjaxResult importTemplate(){
ExcelUtil<TLpgDeliveryRecordImportVo> util = new ExcelUtil<>(TLpgDeliveryRecordImportVo.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
{
if(!isEnterprise()) {
return AjaxResult.error("只支持 企业端导入!!!");
}
ExcelUtil<TLpgDeliveryRecordImportVo> util = new ExcelUtil<>(TLpgDeliveryRecordImportVo.class);
List<TLpgDeliveryRecordImportVo> XmbhList = util.importExcel(file.getInputStream());
String deptId = SecurityUtils.getLoginUser().getUser().getDeptId();
String message = tLpgDeliveryRecordService.importLpgDelivertyRecordInfo(XmbhList, updateSupport, deptId,response);
return AjaxResult.success(message);
}
/**
* 判断是否为企业
* @return r
*/
private boolean isEnterprise(){
List<SysRole> roles = SecurityUtils.getLoginUser().getUser().getRoles();
List<String> roleKeys = roles.stream().map(item -> item.getRoleKey()).collect(Collectors.toList());
return roleKeys.contains("qy");
}
/**
* 获取液化石油配送记录详细信息
*/
......
......@@ -58,6 +58,8 @@ public class TLpgDeliveryRecord extends BaseEntity
/** 删除状态:0.否 1.是 */
private String isDel;
private Long userId;
public void setDeliveryRecordId(Long deliveryRecordId)
{
this.deliveryRecordId = deliveryRecordId;
......@@ -158,6 +160,14 @@ public class TLpgDeliveryRecord extends BaseEntity
return isDel;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
......
package com.zehong.system.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zehong.common.annotation.Excel;
import java.util.Date;
/**
* 液化石油配送记录对象 t_lpg_delivery_record
*
* @author zehong
* @date 2024-09-10
*/
public class TLpgDeliveryRecordImportVo {
/** 储配站 */
@Excel(name = "储配站")
private Long stationName;
@Excel(name = "气瓶条码")
private String fQRcode;
/** 配送人员 */
@Excel(name = "配送人员")
private String deliveryPerson;
/** 车辆代码 */
@Excel(name = "车辆代码")
private String vehicleCode;
/** 用户账号 */
@Excel(name = "用户自有编号")
private String userOwnId;
/** 用户名称 */
@Excel(name = "用户名称")
private String nickName;
/** 地址 */
@Excel(name = "地址")
private String address;
/** 电话 */
@Excel(name = "电话")
private String phone;
/** 0.居民 1.非居民 */
@Excel(name = "用户类型(0=居民,1=非居民)",readConverterExp = "0=居民,1=非居民")
private String gasUserType;
/** 配送地址 */
@Excel(name = "配送地址")
private String deliveryAddress;
/** 配送时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "配送时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date deliveryDate;
public Long getStationName() {
return stationName;
}
public void setStationName(Long stationName) {
this.stationName = stationName;
}
public String getfQRcode() {
return fQRcode;
}
public void setfQRcode(String fQRcode) {
this.fQRcode = fQRcode;
}
public String getDeliveryPerson() {
return deliveryPerson;
}
public void setDeliveryPerson(String deliveryPerson) {
this.deliveryPerson = deliveryPerson;
}
public String getVehicleCode() {
return vehicleCode;
}
public void setVehicleCode(String vehicleCode) {
this.vehicleCode = vehicleCode;
}
public String getUserOwnId() {
return userOwnId;
}
public void setUserOwnId(String userOwnId) {
this.userOwnId = userOwnId;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getGasUserType() {
return gasUserType;
}
public void setGasUserType(String gasUserType) {
this.gasUserType = gasUserType;
}
public String getDeliveryAddress() {
return deliveryAddress;
}
public void setDeliveryAddress(String deliveryAddress) {
this.deliveryAddress = deliveryAddress;
}
public Date getDeliveryDate() {
return deliveryDate;
}
public void setDeliveryDate(Date deliveryDate) {
this.deliveryDate = deliveryDate;
}
}
......@@ -24,6 +24,23 @@ public interface TYehuaqiUserMapper
*/
public TYehuaqiUser selectTYehuaqiUserById(Long userId);
/**
* 根据 企业id 和 用户自有id 查询数据
* @param beyondEnterpriseId b
* @param userOwnId u
* @return r
*/
public TYehuaqiUser selectByUserOwnIdAndBeyondEnterpriseId(String beyondEnterpriseId,String userOwnId);
/**
* 根据 用户名称,电话,地址查询数据
* @param nickName u
* @param phone p
* @param address a
* @return r
*/
public List<TYehuaqiUser> selectByUsernameAndPhoneAndAddress(String nickName,String phone,String address);
/**
* 查询燃气用户列表
*
......
......@@ -2,6 +2,10 @@ package com.zehong.system.service;
import java.util.List;
import com.zehong.system.domain.TLpgDeliveryRecord;
import com.zehong.system.domain.vo.TLpgDeliveryRecordImportVo;
import com.zehong.system.domain.vo.UserManageGasUserExportVo;
import javax.servlet.http.HttpServletResponse;
/**
* 液化石油配送记录Service接口
......@@ -19,6 +23,17 @@ public interface ITLpgDeliveryRecordService
*/
public TLpgDeliveryRecord selectTLpgDeliveryRecordById(Long deliveryRecordId);
/**
* 配送记录数据
*
* @param XmbhList 用户数据列表
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
* @param deptId 操作用户
* @return 结果
*/
public String importLpgDelivertyRecordInfo(List<TLpgDeliveryRecordImportVo> XmbhList, Boolean isUpdateSupport, String deptId, HttpServletResponse response);
/**
* 查询液化石油配送记录列表
*
......
package com.zehong.system.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.TYehuaqiUser;
import com.zehong.system.domain.vo.TLpgDeliveryRecordImportVo;
import com.zehong.system.mapper.TYehuaqiUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TLpgDeliveryRecordMapper;
import com.zehong.system.domain.TLpgDeliveryRecord;
import com.zehong.system.service.ITLpgDeliveryRecordService;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
/**
* 液化石油配送记录Service业务层处理
*
......@@ -17,9 +25,12 @@ import com.zehong.system.service.ITLpgDeliveryRecordService;
@Service
public class TLpgDeliveryRecordServiceImpl implements ITLpgDeliveryRecordService
{
@Autowired
@Resource
private TLpgDeliveryRecordMapper tLpgDeliveryRecordMapper;
@Resource
private TYehuaqiUserMapper yehuaqiUserMapper;
/**
* 查询液化石油配送记录
*
......@@ -32,6 +43,75 @@ public class TLpgDeliveryRecordServiceImpl implements ITLpgDeliveryRecordService
return tLpgDeliveryRecordMapper.selectTLpgDeliveryRecordById(deliveryRecordId);
}
/**
* 数据导入
* @param XmbhList 用户数据列表
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
* @param deptId 操作用户
* @param response r
* @return r
*/
@Override
public String importLpgDelivertyRecordInfo(List<TLpgDeliveryRecordImportVo> XmbhList, Boolean isUpdateSupport, String deptId, HttpServletResponse response) {
for (TLpgDeliveryRecordImportVo tLpgDeliveryRecordImportVo : XmbhList) {
System.out.println(tLpgDeliveryRecordImportVo.getNickName());
System.out.println(tLpgDeliveryRecordImportVo.getDeliveryAddress());
}
System.out.println("deptId = " + deptId);
Integer errorNum = 0;
Integer successNum = 0;
List<TLpgDeliveryRecord> successData = new ArrayList<>();
TLpgDeliveryRecord lpgDeliveryRecord;
for (TLpgDeliveryRecordImportVo tLpgDeliveryRecordImportVo : XmbhList) {
lpgDeliveryRecord = new TLpgDeliveryRecord();
// 如果都为空 则 返回
if (StringUtils.isBlank(tLpgDeliveryRecordImportVo.getNickName())
&& StringUtils.isBlank(tLpgDeliveryRecordImportVo.getPhone())
&& StringUtils.isBlank(tLpgDeliveryRecordImportVo.getAddress())
&& StringUtils.isBlank(tLpgDeliveryRecordImportVo.getUserOwnId())) {
errorNum ++;
continue;
}
// 如果 用户名 + 电话 + 地址 其中一个为空,则 userOwnId 不许为空
if((StringUtils.isBlank(tLpgDeliveryRecordImportVo.getNickName()) ||
StringUtils.isBlank(tLpgDeliveryRecordImportVo.getPhone()) ||
StringUtils.isBlank(tLpgDeliveryRecordImportVo.getAddress()))
&& StringUtils.isBlank(tLpgDeliveryRecordImportVo.getUserOwnId())) {
errorNum ++;
continue;
}
if (StringUtils.isNotBlank(tLpgDeliveryRecordImportVo.getUserOwnId())) {
TYehuaqiUser yehuaqiUser = yehuaqiUserMapper.selectByUserOwnIdAndBeyondEnterpriseId(deptId, tLpgDeliveryRecordImportVo.getUserOwnId());
if (yehuaqiUser == null) {
List<TYehuaqiUser> yehuaqiUsers = yehuaqiUserMapper.selectByUsernameAndPhoneAndAddress(tLpgDeliveryRecordImportVo.getNickName(),
tLpgDeliveryRecordImportVo.getPhone(), tLpgDeliveryRecordImportVo.getAddress());
if (yehuaqiUsers == null || yehuaqiUsers.size() == 0) {
errorNum ++;
continue;
} else {
lpgDeliveryRecord.setUserId(yehuaqiUsers.get(0).getUserId());
}
} else {
lpgDeliveryRecord.setUserId(yehuaqiUser.getUserId());
}
}
}
return null;
}
/**
* 查询液化石油配送记录列表
*
......
......@@ -18,6 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
<result property="isDel" column="is_del" />
<result property="remark" column="remark" />
<result property="userId" column="user_id" />
</resultMap>
<sql id="selectTLpgDeliveryRecordVo">
......@@ -35,6 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
delivery.update_time,
delivery.is_del,
delivery.remark,
delivery.user_id,
bottle.f_q_rcode as fQRcode
FROM
t_lpg_delivery_record delivery
......@@ -77,6 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">update_time,</if>
<if test="isDel != null">is_del,</if>
<if test="remark != null">remark,</if>
<if test="userId != null">user_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="stationName != null">#{stationName},</if>
......@@ -91,6 +94,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">#{updateTime},</if>
<if test="isDel != null">#{isDel},</if>
<if test="remark != null">#{remark},</if>
<if test="userId != null">#{userId},</if>
</trim>
</insert>
......@@ -109,6 +113,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="isDel != null">is_del = #{isDel},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="userId != null">user_id = #{userId},</if>
</trim>
where delivery_record_id = #{deliveryRecordId}
</update>
......
......@@ -26,6 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="villageId" column="f_village_id" />
<result property="villageName" column="village_name" />
<result property="errorMsg" column="error_msg" />
<result property="userOwnId" column="user_own_id" />
</resultMap>
<resultMap type="TYehuaqiUser" id="TYehuaqiUserExportResult">
......@@ -71,16 +72,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectTYehuaqiUserVo">
select user_id, username, nick_name, beyond_enterprise_id, user_type, address, longitude, latitude, linkman,
phone, email, create_time, update_time, is_del, remarks ,f_village_id,error_msg from t_yehuaqi_user
phone, email, create_time, update_time, is_del, remarks ,f_village_id,error_msg,user_own_id from t_yehuaqi_user
</sql>
<select id="selectTYehuaqiUserList" parameterType="TYehuaqiUser" resultMap="TYehuaqiUserResult">
<!-- <include refid="selectTYehuaqiUserVo"/>-->
<!-- <where> -->
<!-- <if test="username != null and username != ''"> and username like concat('%', #{username}, '%')</if>-->
<!-- <if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>-->
<!-- <if test="phone != null and phone != ''"> and phone like concat('%', #{phone}, '%')</if>-->
<!-- </where>-->
select a.user_id,
a.username,
......@@ -120,6 +115,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectTYehuaqiUserVo"/>
where user_id = #{userId}
</select>
<select id="selectByUserOwnIdAndBeyondEnterpriseId" resultMap="TYehuaqiUserResult">
<include refid="selectTYehuaqiUserVo"/>
where beyond_enterprise_id = #{beyondEnterpriseId} and user_own_id = #{userOwnId}
</select>
<select id="selectByUsernameAndPhoneAndAddress" resultMap="TYehuaqiUserResult">
<include refid="selectTYehuaqiUserVo"/>
where nick_name = #{nickName} and phone = #{phone} and address = #{address}
</select>
<select id="queryErrorDetectorUserList" parameterType="string" resultMap="TYehuaqiUserResult">
select * from t_yehuaqi_user where error_msg is not null
......
......@@ -17,6 +17,14 @@ export function getRecord(deliveryRecordId) {
})
}
// 下载用户导入模板
export function importTemplate() {
return request({
url: '/lpg/record/importTemplate',
method: 'get'
})
}
// 新增液化石油配送记录
export function addRecord(data) {
return request({
......
......@@ -76,6 +76,16 @@
:loading="exportLoading"
@click="handleExport"
>导出</el-button>
<el-col :span="1.5">
<el-button
type="info"
icon="el-icon-upload2"
size="mini"
v-if="user.roleId==5"
@click="handleImport">导入</el-button>
</el-col>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
......@@ -183,12 +193,44 @@
<!-- 详情 -->
<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>仅允许导入xlsxlsx格式文件。</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>
</template>
<script>
import { listRecord, getRecord, delRecord, addRecord, updateRecord, exportRecord } from "@/api/lpgRegulation/record";
import { listRecord, getRecord, delRecord, addRecord, updateRecord, exportRecord,importTemplate} from "@/api/lpgRegulation/record";
import DetailInfo from "./components/DetailInfo";
import{getInfo} from "@/api/login"
import { getToken } from "@/utils/auth";
export default {
name: "Record",
components: {
......@@ -196,6 +238,25 @@ export default {
},
data() {
return {
upload: {
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: "",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/lpg/record/importData" // todo
},
user:{},
// 遮罩层
loading: true,
// 导出遮罩层
......@@ -238,9 +299,47 @@ export default {
};
},
created() {
this.getuserInfo();
this.getList();
},
methods: {
getuserInfo(){
getInfo().then(response => {
this.user = response.user.roles[0]
});
},
/** 下载模板操作 */
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.getList();
},
// 提交上传文件
submitFileForm() {
this.$refs.upload.submit();
},
/** 查询液化石油配送记录列表 */
getList() {
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