Commit 61f97d65 authored by 耿迪迪's avatar 耿迪迪

储配站

parent b3e6e8f0
package com.zehong.web.controller.gasBottleTrack;
import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.TGasStorageStationInfo;
import com.zehong.system.service.ITGasStorageStationInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* 储配站信息Controller
*
* @author zehong
* @date 2023-08-14
*/
@RestController
@RequestMapping("/gasBottleTrack/storageStationManage")
public class TGasStorageStationInfoController extends BaseController
{
@Autowired
private ITGasStorageStationInfoService tGasStorageStationInfoService;
/**
* 查询储配站信息列表
*/
@PreAuthorize("@ss.hasPermi('gasBottleTrack:storageStationManage:list')")
@GetMapping("/list")
public TableDataInfo list(TGasStorageStationInfo tGasStorageStationInfo)
{
startPage();
List<TGasStorageStationInfo> list = tGasStorageStationInfoService.selectTGasStorageStationInfoList(tGasStorageStationInfo);
return getDataTable(list);
}
/**
* 导出储配站信息列表
*/
@PreAuthorize("@ss.hasPermi('gasBottleTrack:storageStationManage::export')")
@Log(title = "储配站信息", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TGasStorageStationInfo tGasStorageStationInfo)
{
List<TGasStorageStationInfo> list = tGasStorageStationInfoService.selectTGasStorageStationInfoList(tGasStorageStationInfo);
ExcelUtil<TGasStorageStationInfo> util = new ExcelUtil<TGasStorageStationInfo>(TGasStorageStationInfo.class);
return util.exportExcel(list, "储配站信息数据");
}
/**
* 获取储配站信息详细信息
*/
@PreAuthorize("@ss.hasPermi('gasBottleTrack:storageStationManage:query')")
@GetMapping(value = "/{stationId}")
public AjaxResult getInfo(@PathVariable("stationId") Long stationId)
{
return AjaxResult.success(tGasStorageStationInfoService.selectTGasStorageStationInfoById(stationId));
}
/**
* 新增储配站信息
*/
@PreAuthorize("@ss.hasPermi('gasBottleTrack:storageStationManage:add')")
@Log(title = "储配站信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TGasStorageStationInfo tGasStorageStationInfo)
{
return toAjax(tGasStorageStationInfoService.insertTGasStorageStationInfo(tGasStorageStationInfo));
}
/**
* 修改储配站信息
*/
@PreAuthorize("@ss.hasPermi('gasBottleTrack:storageStationManage:edit')")
@Log(title = "储配站信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TGasStorageStationInfo tGasStorageStationInfo)
{
return toAjax(tGasStorageStationInfoService.updateTGasStorageStationInfo(tGasStorageStationInfo));
}
/**
* 删除储配站信息
*/
@PreAuthorize("@ss.hasPermi('gasBottleTrack:storageStationManage:remove')")
@Log(title = "储配站信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{stationIds}")
public AjaxResult remove(@PathVariable Long[] stationIds)
{
return toAjax(tGasStorageStationInfoService.deleteTGasStorageStationInfoByIds(stationIds));
}
/**
* 储配站导入
* @param file
* @param updateSupport
* @return
* @throws Exception
*/
@PreAuthorize("@ss.hasPermi('gasBottleTrack:storageStationManage:import')")
@Log(title = "储配站维护", businessType = BusinessType.IMPORT)
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
{
ExcelUtil<TGasStorageStationInfo> util = new ExcelUtil<>(TGasStorageStationInfo.class);
List<TGasStorageStationInfo> tGasStorageStationInfoList = util.importExcel(file.getInputStream());
String message = tGasStorageStationInfoService.importTGasStorageStationInfo(tGasStorageStationInfoList, updateSupport);
return AjaxResult.success(message);
}
@GetMapping("/importTemplate")
public AjaxResult importTemplate(){
ExcelUtil<TGasStorageStationInfo> util = new ExcelUtil<>(TGasStorageStationInfo.class);
return util.importTemplateExcel("储配站数据");
}
}
package com.zehong.system.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
/**
* 储配站信息对象 t_gas_storage_station_info
*
* @author zehong
* @date 2023-08-14
*/
public class TGasStorageStationInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 储配站主键 */
private Long stationId;
/** 名称 */
@Excel(name = "储配站名称")
private String stationName;
/** 代码 */
@Excel(name = "储配站编号")
private String stationCode;
/** 负责人 */
@Excel(name = "负责人")
private String director;
/** 联系电话 */
@Excel(name = "联系电话")
private String telNum;
/** 地址 */
@Excel(name = "地址")
private String address;
/** 许可证文件 */
@Excel(name = "许可证文件")
private String licenceFile;
/** 许可证编号 */
@Excel(name = "许可证编号")
private String licenceCode;
/** 许可证有效时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "许可证日期起", width = 30, dateFormat = "yyyy-MM-dd")
private Date licenceEffectiveDate;
/** 许可证有效期截止日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "许可证日期止", width = 30, dateFormat = "yyyy-MM-dd")
private Date licenceLimitDate;
/** 经度 */
@Excel(name = "经度")
private BigDecimal longitude;
/** 纬度 */
@Excel(name = "纬度")
private BigDecimal latitude;
private Date createBeginTime;
private Date createEndTime;
public void setStationId(Long stationId)
{
this.stationId = stationId;
}
public Long getStationId()
{
return stationId;
}
public void setStationName(String stationName)
{
this.stationName = stationName;
}
public String getStationName()
{
return stationName;
}
public void setStationCode(String stationCode)
{
this.stationCode = stationCode;
}
public String getStationCode()
{
return stationCode;
}
public void setDirector(String director)
{
this.director = director;
}
public String getDirector()
{
return director;
}
public void setTelNum(String telNum)
{
this.telNum = telNum;
}
public String getTelNum()
{
return telNum;
}
public void setAddress(String address)
{
this.address = address;
}
public String getAddress()
{
return address;
}
public void setLicenceFile(String licenceFile)
{
this.licenceFile = licenceFile;
}
public String getLicenceFile()
{
return licenceFile;
}
public void setLicenceCode(String licenceCode)
{
this.licenceCode = licenceCode;
}
public String getLicenceCode()
{
return licenceCode;
}
public void setLicenceEffectiveDate(Date licenceEffectiveDate)
{
this.licenceEffectiveDate = licenceEffectiveDate;
}
public Date getLicenceEffectiveDate()
{
return licenceEffectiveDate;
}
public void setLicenceLimitDate(Date licenceLimitDate)
{
this.licenceLimitDate = licenceLimitDate;
}
public Date getLicenceLimitDate()
{
return licenceLimitDate;
}
public void setLongitude(BigDecimal longitude)
{
this.longitude = longitude;
}
public BigDecimal getLongitude()
{
return longitude;
}
public void setLatitude(BigDecimal latitude)
{
this.latitude = latitude;
}
public BigDecimal getLatitude()
{
return latitude;
}
public Date getCreateBeginTime() {
return createBeginTime;
}
public void setCreateBeginTime(Date createBeginTime) {
this.createBeginTime = createBeginTime;
}
public Date getCreateEndTime() {
return createEndTime;
}
public void setCreateEndTime(Date createEndTime) {
this.createEndTime = createEndTime;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("stationId", getStationId())
.append("stationName", getStationName())
.append("stationCode", getStationCode())
.append("director", getDirector())
.append("telNum", getTelNum())
.append("address", getAddress())
.append("licenceFile", getLicenceFile())
.append("licenceCode", getLicenceCode())
.append("licenceEffectiveDate", getLicenceEffectiveDate())
.append("licenceLimitDate", getLicenceLimitDate())
.append("longitude", getLongitude())
.append("latitude", getLatitude())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}
package com.zehong.system.mapper;
import java.util.List;
import com.zehong.system.domain.TGasStorageStationInfo;
/**
* 储配站信息Mapper接口
*
* @author zehong
* @date 2023-08-14
*/
public interface TGasStorageStationInfoMapper
{
/**
* 查询储配站信息
*
* @param stationId 储配站信息ID
* @return 储配站信息
*/
public TGasStorageStationInfo selectTGasStorageStationInfoById(Long stationId);
/**
* 查询储配站信息列表
*
* @param tGasStorageStationInfo 储配站信息
* @return 储配站信息集合
*/
public List<TGasStorageStationInfo> selectTGasStorageStationInfoList(TGasStorageStationInfo tGasStorageStationInfo);
/**
* 新增储配站信息
*
* @param tGasStorageStationInfo 储配站信息
* @return 结果
*/
public int insertTGasStorageStationInfo(TGasStorageStationInfo tGasStorageStationInfo);
/**
* 修改储配站信息
*
* @param tGasStorageStationInfo 储配站信息
* @return 结果
*/
public int updateTGasStorageStationInfo(TGasStorageStationInfo tGasStorageStationInfo);
/**
* 删除储配站信息
*
* @param stationId 储配站信息ID
* @return 结果
*/
public int deleteTGasStorageStationInfoById(Long stationId);
/**
* 批量删除储配站信息
*
* @param stationIds 需要删除的数据ID
* @return 结果
*/
public int deleteTGasStorageStationInfoByIds(Long[] stationIds);
}
package com.zehong.system.service;
import java.util.List;
import com.zehong.system.domain.TGasStorageStationInfo;
/**
* 储配站信息Service接口
*
* @author zehong
* @date 2023-08-14
*/
public interface ITGasStorageStationInfoService
{
/**
* 查询储配站信息
*
* @param stationId 储配站信息ID
* @return 储配站信息
*/
public TGasStorageStationInfo selectTGasStorageStationInfoById(Long stationId);
/**
* 查询储配站信息列表
*
* @param tGasStorageStationInfo 储配站信息
* @return 储配站信息集合
*/
public List<TGasStorageStationInfo> selectTGasStorageStationInfoList(TGasStorageStationInfo tGasStorageStationInfo);
/**
* 新增储配站信息
*
* @param tGasStorageStationInfo 储配站信息
* @return 结果
*/
public int insertTGasStorageStationInfo(TGasStorageStationInfo tGasStorageStationInfo);
/**
* 修改储配站信息
*
* @param tGasStorageStationInfo 储配站信息
* @return 结果
*/
public int updateTGasStorageStationInfo(TGasStorageStationInfo tGasStorageStationInfo);
/**
* 批量删除储配站信息
*
* @param stationIds 需要删除的储配站信息ID
* @return 结果
*/
public int deleteTGasStorageStationInfoByIds(Long[] stationIds);
/**
* 删除储配站信息信息
*
* @param stationId 储配站信息ID
* @return 结果
*/
public int deleteTGasStorageStationInfoById(Long stationId);
/**
* 导入数据
*
* @param tGasStorageStationInfoList 数据列表
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
* @return 结果
*/
String importTGasStorageStationInfo(List<TGasStorageStationInfo> tGasStorageStationInfoList, Boolean isUpdateSupport);
}
package com.zehong.system.service.impl;
import com.zehong.common.exception.CustomException;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.TGasStorageStationInfo;
import com.zehong.system.mapper.TGasStorageStationInfoMapper;
import com.zehong.system.service.ITGasStorageStationInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 储配站信息Service业务层处理
*
* @author zehong
* @date 2023-08-14
*/
@Service
public class TGasStorageStationInfoServiceImpl implements ITGasStorageStationInfoService
{
private static final Logger log = LoggerFactory.getLogger(TGasStorageStationInfoServiceImpl.class);
@Autowired
private TGasStorageStationInfoMapper tGasStorageStationInfoMapper;
/**
* 查询储配站信息
*
* @param stationId 储配站信息ID
* @return 储配站信息
*/
@Override
public TGasStorageStationInfo selectTGasStorageStationInfoById(Long stationId)
{
return tGasStorageStationInfoMapper.selectTGasStorageStationInfoById(stationId);
}
/**
* 查询储配站信息列表
*
* @param tGasStorageStationInfo 储配站信息
* @return 储配站信息
*/
@Override
public List<TGasStorageStationInfo> selectTGasStorageStationInfoList(TGasStorageStationInfo tGasStorageStationInfo)
{
return tGasStorageStationInfoMapper.selectTGasStorageStationInfoList(tGasStorageStationInfo);
}
/**
* 新增储配站信息
*
* @param tGasStorageStationInfo 储配站信息
* @return 结果
*/
@Override
public int insertTGasStorageStationInfo(TGasStorageStationInfo tGasStorageStationInfo)
{
tGasStorageStationInfo.setCreateTime(DateUtils.getNowDate());
return tGasStorageStationInfoMapper.insertTGasStorageStationInfo(tGasStorageStationInfo);
}
/**
* 修改储配站信息
*
* @param tGasStorageStationInfo 储配站信息
* @return 结果
*/
@Override
public int updateTGasStorageStationInfo(TGasStorageStationInfo tGasStorageStationInfo)
{
tGasStorageStationInfo.setUpdateTime(DateUtils.getNowDate());
return tGasStorageStationInfoMapper.updateTGasStorageStationInfo(tGasStorageStationInfo);
}
/**
* 批量删除储配站信息
*
* @param stationIds 需要删除的储配站信息ID
* @return 结果
*/
@Override
public int deleteTGasStorageStationInfoByIds(Long[] stationIds)
{
return tGasStorageStationInfoMapper.deleteTGasStorageStationInfoByIds(stationIds);
}
/**
* 删除储配站信息信息
*
* @param stationId 储配站信息ID
* @return 结果
*/
@Override
public int deleteTGasStorageStationInfoById(Long stationId)
{
return tGasStorageStationInfoMapper.deleteTGasStorageStationInfoById(stationId);
}
/**
* 导入数据
*
* @param tGasStorageStationInfoList 数据列表
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
* @return 结果
*/
@Override
public String importTGasStorageStationInfo(List<TGasStorageStationInfo> tGasStorageStationInfoList, Boolean isUpdateSupport){
if (StringUtils.isNull(tGasStorageStationInfoList) || tGasStorageStationInfoList.size() == 0){
throw new CustomException("导入数据不能为空!");
}
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
for (TGasStorageStationInfo tGasStorageStationInfo : tGasStorageStationInfoList)
{
try {
TGasStorageStationInfo queryGasStorageStationInfo = new TGasStorageStationInfo();
queryGasStorageStationInfo.setStationName(tGasStorageStationInfo.getStationName());
List<TGasStorageStationInfo> gasStorageStationInfos = tGasStorageStationInfoMapper.selectTGasStorageStationInfoList(queryGasStorageStationInfo);
if (StringUtils.isNull(gasStorageStationInfos) || gasStorageStationInfos.size() == 0){
this.insertTGasStorageStationInfo(tGasStorageStationInfo);
successNum++;
successMsg.append("<br/>" + successNum + "、储配站 " + tGasStorageStationInfo.getStationName() + " 导入成功");
}
else if (isUpdateSupport){
gasStorageStationInfos.stream().forEach(stationInfo ->{
tGasStorageStationInfo.setStationId(stationInfo.getStationId());
this.updateTGasStorageStationInfo(tGasStorageStationInfo);
});
successNum++;
successMsg.append("<br/>" + successNum + "、储配站 " + tGasStorageStationInfo.getStationName() + " 更新成功");
}else{
failureNum++;
failureMsg.append("<br/>" + failureNum + "、储配站 " + tGasStorageStationInfo.getStationName() + " 已存在");
}
}
catch (Exception e)
{
failureNum++;
String msg = "<br/>" + failureNum + "、储配站 " + tGasStorageStationInfo.getStationName() + " 导入失败:";
failureMsg.append(msg + e.getMessage());
log.error(msg, e);
}
}
if (failureNum > 0)
{
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new CustomException(failureMsg.toString());
}
else
{
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zehong.system.mapper.TGasStorageStationInfoMapper">
<resultMap type="TGasStorageStationInfo" id="TGasStorageStationInfoResult">
<result property="stationId" column="station_id" />
<result property="stationName" column="station_name" />
<result property="stationCode" column="station_code" />
<result property="director" column="director" />
<result property="telNum" column="tel_num" />
<result property="address" column="address" />
<result property="licenceFile" column="licence_file" />
<result property="licenceCode" column="licence_code" />
<result property="licenceEffectiveDate" column="licence_effective_date" />
<result property="licenceLimitDate" column="licence_limit_date" />
<result property="longitude" column="longitude" />
<result property="latitude" column="latitude" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectTGasStorageStationInfoVo">
select station_id, station_name, station_code, director, tel_num, address, licence_file, licence_code, licence_effective_date, licence_limit_date, longitude, latitude, create_time, update_time, remark from t_gas_storage_station_info
</sql>
<select id="selectTGasStorageStationInfoList" parameterType="TGasStorageStationInfo" resultMap="TGasStorageStationInfoResult">
<include refid="selectTGasStorageStationInfoVo"/>
<where>
<if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
<if test="stationCode != null and stationCode != ''"> and station_code = #{stationCode}</if>
<if test="director != null and director != ''"> and director = #{director}</if>
<if test="telNum != null and telNum != ''"> and tel_num = #{telNum}</if>
<if test="address != null and address != ''"> and address = #{address}</if>
<if test="licenceFile != null and licenceFile != ''"> and licence_file = #{licenceFile}</if>
<if test="licenceCode != null and licenceCode != ''"> and licence_code = #{licenceCode}</if>
<if test="licenceEffectiveDate != null "> and licence_effective_date = #{licenceEffectiveDate}</if>
<if test="licenceLimitDate != null "> and licence_limit_date = #{licenceLimitDate}</if>
<if test="longitude != null "> and longitude = #{longitude}</if>
<if test="latitude != null "> and latitude = #{latitude}</if>
<if test="createBeginTime != null and createEndTime != null">
and create_time BETWEEN #{createBeginTime} AND #{createEndTime}
</if>
</where>
</select>
<select id="selectTGasStorageStationInfoById" parameterType="Long" resultMap="TGasStorageStationInfoResult">
<include refid="selectTGasStorageStationInfoVo"/>
where station_id = #{stationId}
</select>
<insert id="insertTGasStorageStationInfo" parameterType="TGasStorageStationInfo" useGeneratedKeys="true" keyProperty="stationId">
insert into t_gas_storage_station_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="stationName != null">station_name,</if>
<if test="stationCode != null">station_code,</if>
<if test="director != null">director,</if>
<if test="telNum != null">tel_num,</if>
<if test="address != null">address,</if>
<if test="licenceFile != null">licence_file,</if>
<if test="licenceCode != null">licence_code,</if>
<if test="licenceEffectiveDate != null">licence_effective_date,</if>
<if test="licenceLimitDate != null">licence_limit_date,</if>
<if test="longitude != null">longitude,</if>
<if test="latitude != null">latitude,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="stationName != null">#{stationName},</if>
<if test="stationCode != null">#{stationCode},</if>
<if test="director != null">#{director},</if>
<if test="telNum != null">#{telNum},</if>
<if test="address != null">#{address},</if>
<if test="licenceFile != null">#{licenceFile},</if>
<if test="licenceCode != null">#{licenceCode},</if>
<if test="licenceEffectiveDate != null">#{licenceEffectiveDate},</if>
<if test="licenceLimitDate != null">#{licenceLimitDate},</if>
<if test="longitude != null">#{longitude},</if>
<if test="latitude != null">#{latitude},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateTGasStorageStationInfo" parameterType="TGasStorageStationInfo">
update t_gas_storage_station_info
<trim prefix="SET" suffixOverrides=",">
<if test="stationName != null">station_name = #{stationName},</if>
<if test="stationCode != null">station_code = #{stationCode},</if>
<if test="director != null">director = #{director},</if>
<if test="telNum != null">tel_num = #{telNum},</if>
<if test="address != null">address = #{address},</if>
<if test="licenceFile != null">licence_file = #{licenceFile},</if>
<if test="licenceCode != null">licence_code = #{licenceCode},</if>
<if test="licenceEffectiveDate != null">licence_effective_date = #{licenceEffectiveDate},</if>
<if test="licenceLimitDate != null">licence_limit_date = #{licenceLimitDate},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where station_id = #{stationId}
</update>
<delete id="deleteTGasStorageStationInfoById" parameterType="Long">
delete from t_gas_storage_station_info where station_id = #{stationId}
</delete>
<delete id="deleteTGasStorageStationInfoByIds" parameterType="String">
delete from t_gas_storage_station_info where station_id in
<foreach item="stationId" collection="array" open="(" separator="," close=")">
#{stationId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
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