Commit 36ace8f5 authored by wanghao's avatar wanghao

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

parent 90967c58
package com.zehong.web.controller.lpgRegulation;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
......@@ -93,8 +94,8 @@ public class TLpgDeliveryRecordController extends BaseController
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);
HashMap<String, Object> map = tLpgDeliveryRecordService.importLpgDelivertyRecordInfo(XmbhList, updateSupport, deptId, response);
return AjaxResult.success(map);
}
......
......@@ -22,13 +22,10 @@ public class TLpgDeliveryRecord extends BaseEntity
/** 储配站 */
@Excel(name = "储配站")
private Long stationName;
/** 气瓶主键 */
private Long bottleId;
private String stationName;
@Excel(name = "气瓶条码")
private String fQRcode;
private String bottleCode;
/** 配送人员 */
@Excel(name = "配送人员")
......@@ -43,7 +40,7 @@ public class TLpgDeliveryRecord extends BaseEntity
private String gasUser;
/** 0.居民 1.非居民 */
@Excel(name = "用户类型",readConverterExp = "0=居民,1=非居民")
@Excel(name = "用户类型(0=居民,1=非居民)")
private String gasUserType;
/** 配送地址 */
......@@ -69,31 +66,22 @@ public class TLpgDeliveryRecord extends BaseEntity
{
return deliveryRecordId;
}
public void setStationName(Long stationName)
public void setStationName(String stationName)
{
this.stationName = stationName;
}
public Long getStationName()
public String getStationName()
{
return stationName;
}
public void setBottleId(Long bottleId)
{
this.bottleId = bottleId;
}
public Long getBottleId()
{
return bottleId;
public String getBottleCode() {
return bottleCode;
}
public String getfQRcode() {
return fQRcode;
}
public void setfQRcode(String fQRcode) {
this.fQRcode = fQRcode;
public void setBottleCode(String bottleCode) {
this.bottleCode = bottleCode;
}
public void setDeliveryPerson(String deliveryPerson)
......@@ -168,12 +156,12 @@ public class TLpgDeliveryRecord extends BaseEntity
this.userId = userId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("deliveryRecordId", getDeliveryRecordId())
.append("stationName", getStationName())
.append("bottleId", getBottleId())
.append("deliveryPerson", getDeliveryPerson())
.append("vehicleCode", getVehicleCode())
.append("gasUser", getGasUser())
......
......@@ -16,10 +16,10 @@ public class TLpgDeliveryRecordImportVo {
/** 储配站 */
@Excel(name = "储配站")
private Long stationName;
private String stationName;
@Excel(name = "气瓶条码")
private String fQRcode;
private String bottleCode;
/** 配送人员 */
@Excel(name = "配送人员")
......@@ -46,7 +46,7 @@ public class TLpgDeliveryRecordImportVo {
private String phone;
/** 0.居民 1.非居民 */
@Excel(name = "用户类型(0=居民,1=非居民)",readConverterExp = "0=居民,1=非居民")
@Excel(name = "用户类型(0=居民,1=非居民)")
private String gasUserType;
/** 配送地址 */
......@@ -58,20 +58,20 @@ public class TLpgDeliveryRecordImportVo {
@Excel(name = "配送时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date deliveryDate;
public Long getStationName() {
public String getStationName() {
return stationName;
}
public void setStationName(Long stationName) {
public void setStationName(String stationName) {
this.stationName = stationName;
}
public String getfQRcode() {
return fQRcode;
public String getBottleCode() {
return bottleCode;
}
public void setfQRcode(String fQRcode) {
this.fQRcode = fQRcode;
public void setBottleCode(String bottleCode) {
this.bottleCode = bottleCode;
}
public String getDeliveryPerson() {
......
......@@ -2,6 +2,8 @@ package com.zehong.system.mapper;
import java.util.List;
import com.zehong.system.domain.TLpgDeliveryRecord;
import com.zehong.system.domain.TYehuaqiUser;
import org.apache.ibatis.annotations.Param;
/**
* 液化石油配送记录Mapper接口
......@@ -35,6 +37,12 @@ public interface TLpgDeliveryRecordMapper
*/
public int insertTLpgDeliveryRecord(TLpgDeliveryRecord tLpgDeliveryRecord);
/**
* 批量增加
* @param list list
* @return r
*/
public int insertBatch(@Param("list") List<TLpgDeliveryRecord> list);
/**
* 修改液化石油配送记录
*
......
......@@ -30,7 +30,8 @@ public interface TYehuaqiUserMapper
* @param userOwnId u
* @return r
*/
public TYehuaqiUser selectByUserOwnIdAndBeyondEnterpriseId(String beyondEnterpriseId,String userOwnId);
public TYehuaqiUser selectByUserOwnIdAndBeyondEnterpriseId(@Param("beyondEnterpriseId") String beyondEnterpriseId,
@Param("userOwnId") String userOwnId);
/**
* 根据 用户名称,电话,地址查询数据
......@@ -39,7 +40,9 @@ public interface TYehuaqiUserMapper
* @param address a
* @return r
*/
public List<TYehuaqiUser> selectByUsernameAndPhoneAndAddress(String nickName,String phone,String address);
public List<TYehuaqiUser> selectByUsernameAndPhoneAndAddress(@Param("nickName") String nickName,
@Param("phone") String phone,
@Param("address") String address);
/**
* 查询燃气用户列表
......
package com.zehong.system.service;
import java.util.HashMap;
import java.util.List;
import com.zehong.system.domain.TLpgDeliveryRecord;
import com.zehong.system.domain.vo.TLpgDeliveryRecordImportVo;
......@@ -31,7 +32,7 @@ public interface ITLpgDeliveryRecordService
* @param deptId 操作用户
* @return 结果
*/
public String importLpgDelivertyRecordInfo(List<TLpgDeliveryRecordImportVo> XmbhList, Boolean isUpdateSupport, String deptId, HttpServletResponse response);
public HashMap<String,Object> importLpgDelivertyRecordInfo(List<TLpgDeliveryRecordImportVo> XmbhList, Boolean isUpdateSupport, String deptId, HttpServletResponse response);
/**
......
package com.zehong.system.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.TLpgGasBottleFiles;
import com.zehong.system.domain.TYehuaqiUser;
import com.zehong.system.domain.vo.TLpgDeliveryRecordImportVo;
import com.zehong.system.mapper.TLpgGasBottleFilesMapper;
import com.zehong.system.mapper.TYehuaqiUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -31,6 +34,11 @@ public class TLpgDeliveryRecordServiceImpl implements ITLpgDeliveryRecordService
@Resource
private TYehuaqiUserMapper yehuaqiUserMapper;
/**
* 气瓶档案
*/
@Resource
private TLpgGasBottleFilesMapper tLpgGasBottleFilesMapper;
/**
* 查询液化石油配送记录
*
......@@ -52,17 +60,10 @@ public class TLpgDeliveryRecordServiceImpl implements ITLpgDeliveryRecordService
* @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);
public HashMap<String,Object> importLpgDelivertyRecordInfo(List<TLpgDeliveryRecordImportVo> XmbhList, Boolean isUpdateSupport, String deptId, HttpServletResponse response) {
Integer errorNum = 0;
Integer successNum = 0;
int errorNum = 0;
int successNum = 0;
List<TLpgDeliveryRecord> successData = new ArrayList<>();
......@@ -70,6 +71,12 @@ public class TLpgDeliveryRecordServiceImpl implements ITLpgDeliveryRecordService
for (TLpgDeliveryRecordImportVo tLpgDeliveryRecordImportVo : XmbhList) {
lpgDeliveryRecord = new TLpgDeliveryRecord();
// 气瓶条码不许为空
if (StringUtils.isBlank(tLpgDeliveryRecordImportVo.getBottleCode())) {
errorNum++;
continue;
}
// 如果都为空 则 返回
if (StringUtils.isBlank(tLpgDeliveryRecordImportVo.getNickName())
&& StringUtils.isBlank(tLpgDeliveryRecordImportVo.getPhone())
......@@ -89,7 +96,18 @@ public class TLpgDeliveryRecordServiceImpl implements ITLpgDeliveryRecordService
continue;
}
// 气瓶条码处理
TLpgGasBottleFiles tLpgGasBottleFiles = new TLpgGasBottleFiles();
tLpgGasBottleFiles.setfQRcode(tLpgDeliveryRecordImportVo.getBottleCode());
List<TLpgGasBottleFiles> tLpgGasBottleFiles1 = tLpgGasBottleFilesMapper.selectTLpgGasBottleFilesList(tLpgGasBottleFiles);
if (tLpgGasBottleFiles1 == null || tLpgGasBottleFiles1.size() == 0) {
errorNum ++;
continue;
}
lpgDeliveryRecord.setBottleCode(tLpgGasBottleFiles1.get(0).getfQRcode());
// 燃气用户处理
if (StringUtils.isNotBlank(tLpgDeliveryRecordImportVo.getUserOwnId())) {
TYehuaqiUser yehuaqiUser = yehuaqiUserMapper.selectByUserOwnIdAndBeyondEnterpriseId(deptId, tLpgDeliveryRecordImportVo.getUserOwnId());
......@@ -100,16 +118,41 @@ public class TLpgDeliveryRecordServiceImpl implements ITLpgDeliveryRecordService
if (yehuaqiUsers == null || yehuaqiUsers.size() == 0) {
errorNum ++;
continue;
} else {
lpgDeliveryRecord.setUserId(yehuaqiUsers.get(0).getUserId());
}
lpgDeliveryRecord.setUserId(yehuaqiUsers.get(0).getUserId());
} else {
lpgDeliveryRecord.setUserId(yehuaqiUser.getUserId());
}
} else {
List<TYehuaqiUser> yehuaqiUsers = yehuaqiUserMapper.selectByUsernameAndPhoneAndAddress(tLpgDeliveryRecordImportVo.getNickName(),
tLpgDeliveryRecordImportVo.getPhone(), tLpgDeliveryRecordImportVo.getAddress());
if (yehuaqiUsers == null || yehuaqiUsers.size() == 0) {
errorNum ++;
continue;
}
lpgDeliveryRecord.setUserId(yehuaqiUsers.get(0).getUserId());
}
lpgDeliveryRecord.setStationName(tLpgDeliveryRecordImportVo.getStationName());
lpgDeliveryRecord.setBottleCode(tLpgDeliveryRecordImportVo.getBottleCode());
lpgDeliveryRecord.setDeliveryPerson(tLpgDeliveryRecordImportVo.getDeliveryPerson());
lpgDeliveryRecord.setVehicleCode(tLpgDeliveryRecordImportVo.getVehicleCode());
lpgDeliveryRecord.setGasUserType(tLpgDeliveryRecordImportVo.getGasUserType());
lpgDeliveryRecord.setDeliveryAddress(tLpgDeliveryRecordImportVo.getDeliveryAddress());
lpgDeliveryRecord.setDeliveryDate(tLpgDeliveryRecordImportVo.getDeliveryDate());
successData.add(lpgDeliveryRecord);
successNum++;
}
if (successData.size() > 0) {
tLpgDeliveryRecordMapper.insertBatch(successData);
}
HashMap<String,Object> map = new HashMap<>();
map.put("successNum",successNum);
map.put("errorNum",errorNum);
return null;
return map;
}
/**
......
......@@ -7,10 +7,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="TLpgDeliveryRecord" id="TLpgDeliveryRecordResult">
<result property="deliveryRecordId" column="delivery_record_id" />
<result property="stationName" column="station_name" />
<result property="bottleId" column="bottle_id" />
<result property="deliveryPerson" column="delivery_person" />
<result property="vehicleCode" column="vehicle_code" />
<result property="gasUser" column="gas_user" />
<result property="gasUserType" column="gas_user_type" />
<result property="deliveryAddress" column="delivery_address" />
<result property="deliveryDate" column="delivery_date" />
......@@ -19,16 +17,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="isDel" column="is_del" />
<result property="remark" column="remark" />
<result property="userId" column="user_id" />
<result property="bottleCode" column="f_bottle_code" />
<result property="gasUser" column="nickName" />
</resultMap>
<sql id="selectTLpgDeliveryRecordVo">
SELECT
delivery.delivery_record_id,
delivery.station_name,
delivery.bottle_id,
delivery.delivery_person,
delivery.vehicle_code,
delivery.gas_user,
delivery.gas_user_type,
delivery.delivery_address,
delivery.delivery_date,
......@@ -37,25 +35,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
delivery.is_del,
delivery.remark,
delivery.user_id,
bottle.f_q_rcode as fQRcode
delivery.f_bottle_code,
yequser.nick_name as nickName
FROM
t_lpg_delivery_record delivery
LEFT JOIN t_lpg_gas_bottle_files bottle ON delivery.bottle_id = bottle.f_gas_bottle_files_id
left join t_yehuaqi_user yequser on delivery.user_id = yequser.user_id
</sql>
<select id="selectTLpgDeliveryRecordList" parameterType="TLpgDeliveryRecord" resultMap="TLpgDeliveryRecordResult">
<include refid="selectTLpgDeliveryRecordVo"/>
<where>
<if test="stationName != null "> and delivery.station_name like concat('%', #{stationName}, '%')</if>
<if test="bottleId != null "> and delivery.bottle_id = #{bottleId}</if>
<if test="deliveryPerson != null and deliveryPerson != ''"> and delivery.delivery_person like concat('%', #{deliveryPerson}, '%')</if>
<if test="vehicleCode != null and vehicleCode != ''"> and delivery.vehicle_code = #{vehicleCode}</if>
<if test="gasUser != null and gasUser != ''"> and delivery.gas_user like concat('%', #{gasUser}, '%')</if>
<if test="gasUser != null and gasUser != ''"> and yequser.nick_name like concat('%', #{gasUser}, '%')</if>
<if test="gasUserType != null and gasUserType != ''"> and delivery.gas_user_type = #{gasUserType}</if>
<if test="deliveryAddress != null and deliveryAddress != ''"> and delivery.delivery_address = #{deliveryAddress}</if>
<if test="deliveryDate != null "> and delivery.delivery_date = #{deliveryDate}</if>
<if test="isDel != null and isDel != ''"> and delivery.is_del = #{isDel}</if>
<if test="fQRcode != null and fQRcode != ''"> and bottle.f_q_rcode like concat('%', #{fQRcode}, '%')</if>
<if test="bottleCode != null and bottleCode != ''"> and bottle.f_bottle_code like concat('%', #{bottleCode}, '%')</if>
</where>
</select>
......@@ -71,7 +69,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="bottleId != null">bottle_id,</if>
<if test="deliveryPerson != null">delivery_person,</if>
<if test="vehicleCode != null">vehicle_code,</if>
<if test="gasUser != null">gas_user,</if>
<if test="gasUserType != null">gas_user_type,</if>
<if test="deliveryAddress != null">delivery_address,</if>
<if test="deliveryDate != null">delivery_date,</if>
......@@ -86,7 +83,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="bottleId != null">#{bottleId},</if>
<if test="deliveryPerson != null">#{deliveryPerson},</if>
<if test="vehicleCode != null">#{vehicleCode},</if>
<if test="gasUser != null">#{gasUser},</if>
<if test="gasUserType != null">#{gasUserType},</if>
<if test="deliveryAddress != null">#{deliveryAddress},</if>
<if test="deliveryDate != null">#{deliveryDate},</if>
......@@ -98,14 +94,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<insert id="insertBatch" parameterType="list">
insert into t_lpg_delivery_record (station_name, delivery_person,vehicle_code, gas_user_type, delivery_address,
delivery_date,user_id,f_bottle_code)
values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.stationName,jdbcType=VARCHAR}, #{item.deliveryPerson,jdbcType=VARCHAR}, #{item.vehicleCode,jdbcType=VARCHAR},
#{item.gasUserType,jdbcType=VARCHAR}, #{item.deliveryAddress,jdbcType=VARCHAR},
#{item.deliveryDate},#{item.userId},#{item.bottleCode}
)
</foreach>
</insert>
<update id="updateTLpgDeliveryRecord" parameterType="TLpgDeliveryRecord">
update t_lpg_delivery_record
<trim prefix="SET" suffixOverrides=",">
<if test="stationName != null">station_name = #{stationName},</if>
<if test="bottleId != null">bottle_id = #{bottleId},</if>
<if test="bottleCode != null">f_bottle_code = #{bottleCode},</if>
<if test="deliveryPerson != null">delivery_person = #{deliveryPerson},</if>
<if test="vehicleCode != null">vehicle_code = #{vehicleCode},</if>
<if test="gasUser != null">gas_user = #{gasUser},</if>
<if test="gasUserType != null">gas_user_type = #{gasUserType},</if>
<if test="deliveryAddress != null">delivery_address = #{deliveryAddress},</if>
<if test="deliveryDate != null">delivery_date = #{deliveryDate},</if>
......
......@@ -12,14 +12,7 @@
</el-col>
<el-col :span="12">
<el-form-item label="气瓶条码">
<span v-if="detailInfo.fQRcode">{{ detailInfo.fQRcode }}</span>
<span v-else>-</span>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="气瓶条码">
<span v-if="detailInfo.fQRcode">{{ detailInfo.fQRcode }}</span>
<span v-if="detailInfo.bottleCode">{{ detailInfo.bottleCode }}</span>
<span v-else>-</span>
</el-form-item>
</el-col>
......
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="气瓶条码" prop="fQRcode">
<el-form-item label="气瓶条码" prop="bottleCode">
<el-input
v-model="queryParams.fQRcode"
v-model="queryParams.bottleCode"
placeholder="请输入气瓶条码"
clearable
size="small"
......@@ -92,7 +92,7 @@
<el-table v-loading="loading" :data="recordList">
<el-table-column label="储配站" align="center" prop="stationName" />
<el-table-column label="气瓶条码" align="center" prop="fQRcode" />
<el-table-column label="气瓶条码" align="center" prop="bottleCode" />
<el-table-column label="配送人员" align="center" prop="deliveryPerson" />
<el-table-column label="车辆代码" align="center" prop="vehicleCode" />
<el-table-column label="用户" align="center" prop="gasUser" />
......@@ -252,7 +252,7 @@ export default {
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/lpg/record/importData" // todo
url: process.env.VUE_APP_BASE_API + "/lpg/record/importData"
},
user:{},
......@@ -282,7 +282,7 @@ export default {
pageNum: 1,
pageSize: 10,
stationName: null,
fQRcode: null,
bottleCode: null,
deliveryPerson: null,
vehicleCode: null,
gasUser: null,
......@@ -331,7 +331,7 @@ export default {
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.data.successNum + "条,失败:" + response.data.errorNum + "条" + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
this.getList();
},
......
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