Commit 9db6982f authored by 吴卿华's avatar 吴卿华

车辆管理

parent 91487f9c
package com.zehong.web.controller.system;
import java.util.List;
import com.zehong.common.core.domain.model.LoginUser;
import com.zehong.common.utils.ServletUtils;
import com.zehong.framework.web.service.TokenService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.TVehicleUseRecord;
import com.zehong.system.service.ITVehicleUseRecordService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;
/**
* 车辆使用记录Controller
*
* @author zehong
* @date 2023-08-19
*/
@RestController
@RequestMapping("/system/record")
public class TVehicleUseRecordController extends BaseController
{
@Autowired
private ITVehicleUseRecordService tVehicleUseRecordService;
@Autowired
private TokenService tokenService;
/**
* 查询车辆使用记录列表
*/
@PreAuthorize("@ss.hasPermi('system:record:list')")
@GetMapping("/list")
public TableDataInfo list(TVehicleUseRecord tVehicleUseRecord)
{
startPage();
List<TVehicleUseRecord> list = tVehicleUseRecordService.selectTVehicleUseRecordList(tVehicleUseRecord);
return getDataTable(list);
}
/**
* 导出车辆使用记录列表
*/
@PreAuthorize("@ss.hasPermi('system:record:export')")
@Log(title = "车辆使用记录", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TVehicleUseRecord tVehicleUseRecord)
{
List<TVehicleUseRecord> list = tVehicleUseRecordService.selectTVehicleUseRecordList(tVehicleUseRecord);
ExcelUtil<TVehicleUseRecord> util = new ExcelUtil<TVehicleUseRecord>(TVehicleUseRecord.class);
return util.exportExcel(list, "车辆使用记录数据");
}
/**
* 获取车辆使用记录详细信息
*/
@PreAuthorize("@ss.hasPermi('system:record:query')")
@GetMapping(value = "/{vehicleUseRecordId}")
public AjaxResult getInfo(@PathVariable("vehicleUseRecordId") Long vehicleUseRecordId)
{
return AjaxResult.success(tVehicleUseRecordService.selectTVehicleUseRecordById(vehicleUseRecordId));
}
/**
* 新增车辆使用记录
*/
@PreAuthorize("@ss.hasPermi('system:record:add')")
@Log(title = "车辆使用记录", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TVehicleUseRecord tVehicleUseRecord)
{
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
Long userId = loginUser.getUser().getUserId();
tVehicleUseRecord.setVehicleUserId(userId);
return toAjax(tVehicleUseRecordService.insertTVehicleUseRecord(tVehicleUseRecord));
}
/**
* 修改车辆使用记录
*/
@PreAuthorize("@ss.hasPermi('system:record:edit')")
@Log(title = "车辆使用记录", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TVehicleUseRecord tVehicleUseRecord)
{
return toAjax(tVehicleUseRecordService.updateTVehicleUseRecord(tVehicleUseRecord));
}
/**
* 删除车辆使用记录
*/
@PreAuthorize("@ss.hasPermi('system:record:remove')")
@Log(title = "车辆使用记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{vehicleUseRecordIds}")
public AjaxResult remove(@PathVariable Long[] vehicleUseRecordIds)
{
return toAjax(tVehicleUseRecordService.deleteTVehicleUseRecordByIds(vehicleUseRecordIds));
}
}
......@@ -73,14 +73,13 @@ public class TVehicleInfo extends BaseEntity
*/
private String siteStationName;
private BigDecimal longitude;
private BigDecimal latitude;
private String beyondEnterpriseName;
public String getSiteStationName() {
return siteStationName;
}
......
package com.zehong.system.domain;
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_vehicle_use_record
*
* @author zehong
* @date 2023-08-19
*/
public class TVehicleUseRecord extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 车辆使用主键 */
private Long vehicleUseRecordId;
/** 储配站主键 */
@Excel(name = "储配站主键")
private Long stationId;
/** 车辆主键 */
@Excel(name = "车辆主键")
private Long vehicleId;
/** 车牌号 */
@Excel(name = "车牌号")
private String carNum;
/**
* 储配站名称
*/
private String siteStationName;
/**
* 使用人姓名
*/
private String name;
/**
* 车辆编号
*/
private String vehicleCode;
/** 车辆使用人 */
@Excel(name = "车辆使用人")
private Long vehicleUserId;
/** 使用时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "使用时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date vehicleUseDate;
/** 归还时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "归还时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date vehicleReturnDate;
/** 删除状态:0.否 1.是 */
@Excel(name = "删除状态:0.否 1.是")
private String isDel;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getCarNum() {
return carNum;
}
public void setCarNum(String carNum) {
this.carNum = carNum;
}
public String getSiteStationName() {
return siteStationName;
}
public void setSiteStationName(String siteStationName) {
this.siteStationName = siteStationName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getVehicleCode() {
return vehicleCode;
}
public void setVehicleCode(String vehicleCode) {
this.vehicleCode = vehicleCode;
}
public void setVehicleUseRecordId(Long vehicleUseRecordId)
{
this.vehicleUseRecordId = vehicleUseRecordId;
}
public Long getVehicleUseRecordId()
{
return vehicleUseRecordId;
}
public void setStationId(Long stationId)
{
this.stationId = stationId;
}
public Long getStationId()
{
return stationId;
}
public void setVehicleId(Long vehicleId)
{
this.vehicleId = vehicleId;
}
public Long getVehicleId()
{
return vehicleId;
}
public void setVehicleUserId(Long vehicleUserId)
{
this.vehicleUserId = vehicleUserId;
}
public Long getVehicleUserId()
{
return vehicleUserId;
}
public void setVehicleUseDate(Date vehicleUseDate)
{
this.vehicleUseDate = vehicleUseDate;
}
public Date getVehicleUseDate()
{
return vehicleUseDate;
}
public void setVehicleReturnDate(Date vehicleReturnDate)
{
this.vehicleReturnDate = vehicleReturnDate;
}
public Date getVehicleReturnDate()
{
return vehicleReturnDate;
}
public void setIsDel(String isDel)
{
this.isDel = isDel;
}
public String getIsDel()
{
return isDel;
}
@Override
public String toString() {
return "TVehicleUseRecord{" +
"vehicleUseRecordId=" + vehicleUseRecordId +
", stationId=" + stationId +
", vehicleId=" + vehicleId +
", carNum='" + carNum + '\'' +
", siteStationName='" + siteStationName + '\'' +
", name='" + name + '\'' +
", vehicleCode='" + vehicleCode + '\'' +
", vehicleUserId=" + vehicleUserId +
", vehicleUseDate=" + vehicleUseDate +
", vehicleReturnDate=" + vehicleReturnDate +
", isDel='" + isDel + '\'' +
'}';
}
}
package com.zehong.system.mapper;
import java.util.List;
import com.zehong.system.domain.TVehicleUseRecord;
/**
* 车辆使用记录Mapper接口
*
* @author zehong
* @date 2023-08-19
*/
public interface TVehicleUseRecordMapper
{
/**
* 查询车辆使用记录
*
* @param vehicleUseRecordId 车辆使用记录ID
* @return 车辆使用记录
*/
public TVehicleUseRecord selectTVehicleUseRecordById(Long vehicleUseRecordId);
/**
* 查询车辆使用记录列表
*
* @param tVehicleUseRecord 车辆使用记录
* @return 车辆使用记录集合
*/
public List<TVehicleUseRecord> selectTVehicleUseRecordList(TVehicleUseRecord tVehicleUseRecord);
/**
* 新增车辆使用记录
*
* @param tVehicleUseRecord 车辆使用记录
* @return 结果
*/
public int insertTVehicleUseRecord(TVehicleUseRecord tVehicleUseRecord);
/**
* 修改车辆使用记录
*
* @param tVehicleUseRecord 车辆使用记录
* @return 结果
*/
public int updateTVehicleUseRecord(TVehicleUseRecord tVehicleUseRecord);
/**
* 删除车辆使用记录
*
* @param vehicleUseRecordId 车辆使用记录ID
* @return 结果
*/
public int deleteTVehicleUseRecordById(Long vehicleUseRecordId);
/**
* 批量删除车辆使用记录
*
* @param vehicleUseRecordIds 需要删除的数据ID
* @return 结果
*/
public int deleteTVehicleUseRecordByIds(Long[] vehicleUseRecordIds);
}
package com.zehong.system.service;
import java.util.List;
import com.zehong.system.domain.TVehicleUseRecord;
/**
* 车辆使用记录Service接口
*
* @author zehong
* @date 2023-08-19
*/
public interface ITVehicleUseRecordService
{
/**
* 查询车辆使用记录
*
* @param vehicleUseRecordId 车辆使用记录ID
* @return 车辆使用记录
*/
public TVehicleUseRecord selectTVehicleUseRecordById(Long vehicleUseRecordId);
/**
* 查询车辆使用记录列表
*
* @param tVehicleUseRecord 车辆使用记录
* @return 车辆使用记录集合
*/
public List<TVehicleUseRecord> selectTVehicleUseRecordList(TVehicleUseRecord tVehicleUseRecord);
/**
* 新增车辆使用记录
*
* @param tVehicleUseRecord 车辆使用记录
* @return 结果
*/
public int insertTVehicleUseRecord(TVehicleUseRecord tVehicleUseRecord);
/**
* 修改车辆使用记录
*
* @param tVehicleUseRecord 车辆使用记录
* @return 结果
*/
public int updateTVehicleUseRecord(TVehicleUseRecord tVehicleUseRecord);
/**
* 批量删除车辆使用记录
*
* @param vehicleUseRecordIds 需要删除的车辆使用记录ID
* @return 结果
*/
public int deleteTVehicleUseRecordByIds(Long[] vehicleUseRecordIds);
/**
* 删除车辆使用记录信息
*
* @param vehicleUseRecordId 车辆使用记录ID
* @return 结果
*/
public int deleteTVehicleUseRecordById(Long vehicleUseRecordId);
}
package com.zehong.system.service.impl;
import java.util.List;
import com.zehong.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TVehicleUseRecordMapper;
import com.zehong.system.domain.TVehicleUseRecord;
import com.zehong.system.service.ITVehicleUseRecordService;
/**
* 车辆使用记录Service业务层处理
*
* @author zehong
* @date 2023-08-19
*/
@Service
public class TVehicleUseRecordServiceImpl implements ITVehicleUseRecordService
{
@Autowired
private TVehicleUseRecordMapper tVehicleUseRecordMapper;
/**
* 查询车辆使用记录
*
* @param vehicleUseRecordId 车辆使用记录ID
* @return 车辆使用记录
*/
@Override
public TVehicleUseRecord selectTVehicleUseRecordById(Long vehicleUseRecordId)
{
return tVehicleUseRecordMapper.selectTVehicleUseRecordById(vehicleUseRecordId);
}
/**
* 查询车辆使用记录列表
*
* @param tVehicleUseRecord 车辆使用记录
* @return 车辆使用记录
*/
@Override
public List<TVehicleUseRecord> selectTVehicleUseRecordList(TVehicleUseRecord tVehicleUseRecord)
{
return tVehicleUseRecordMapper.selectTVehicleUseRecordList(tVehicleUseRecord);
}
/**
* 新增车辆使用记录
*
* @param tVehicleUseRecord 车辆使用记录
* @return 结果
*/
@Override
public int insertTVehicleUseRecord(TVehicleUseRecord tVehicleUseRecord)
{
tVehicleUseRecord.setCreateTime(DateUtils.getNowDate());
return tVehicleUseRecordMapper.insertTVehicleUseRecord(tVehicleUseRecord);
}
/**
* 修改车辆使用记录
*
* @param tVehicleUseRecord 车辆使用记录
* @return 结果
*/
@Override
public int updateTVehicleUseRecord(TVehicleUseRecord tVehicleUseRecord)
{
tVehicleUseRecord.setUpdateTime(DateUtils.getNowDate());
return tVehicleUseRecordMapper.updateTVehicleUseRecord(tVehicleUseRecord);
}
/**
* 批量删除车辆使用记录
*
* @param vehicleUseRecordIds 需要删除的车辆使用记录ID
* @return 结果
*/
@Override
public int deleteTVehicleUseRecordByIds(Long[] vehicleUseRecordIds)
{
return tVehicleUseRecordMapper.deleteTVehicleUseRecordByIds(vehicleUseRecordIds);
}
/**
* 删除车辆使用记录信息
*
* @param vehicleUseRecordId 车辆使用记录ID
* @return 结果
*/
@Override
public int deleteTVehicleUseRecordById(Long vehicleUseRecordId)
{
return tVehicleUseRecordMapper.deleteTVehicleUseRecordById(vehicleUseRecordId);
}
}
<?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.TVehicleUseRecordMapper">
<resultMap type="TVehicleUseRecord" id="TVehicleUseRecordResult">
<result property="vehicleUseRecordId" column="vehicle_use_record_id" />
<result property="stationId" column="station_id" />
<result property="vehicleId" column="vehicle_id" />
<result property="vehicleUserId" column="vehicle_user_id" />
<result property="vehicleUseDate" column="vehicle_use_date" />
<result property="vehicleReturnDate" column="vehicle_return_date" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="isDel" column="is_del" />
<result property="remark" column="remark" />
<result property="carNum" column="car_num" />
<result property="siteStationName" column="station_name" />
<result property="name" column="nick_name" />
<result property="vehicleCode" column="vehicle_code" />
</resultMap>
<sql id="selectTVehicleUseRecordVo">
select vehicle_use_record_id, station_id, vehicle_id, vehicle_user_id, vehicle_use_date, vehicle_return_date, create_time, update_time, is_del, remark from t_vehicle_use_record
</sql>
<select id="selectTVehicleUseRecordList" parameterType="TVehicleUseRecord" resultMap="TVehicleUseRecordResult">
select a.vehicle_use_record_id, a.station_id, a.vehicle_id, a.vehicle_user_id, a.vehicle_use_date, a.vehicle_return_date, a.create_time, a.update_time, a.is_del, a.remark,
b.station_name,c.vehicle_code,c.car_num,d.nick_name
from t_vehicle_use_record a
left join t_gas_storage_station_info b on a.station_id=b.station_id
left join t_vehicle_info c on a.vehicle_id=c.vehicle_id
left join sys_user d on a.vehicle_user_id=d.user_id
<where>
<if test="stationId != null "> and a.station_id = #{stationId}</if>
<if test="vehicleId != null "> and a.vehicle_id = #{vehicleId}</if>
<if test="vehicleUserId != null "> and a.vehicle_user_id = #{vehicleUserId}</if>
<if test="vehicleUseDate != null "> and a.vehicle_use_date = #{vehicleUseDate}</if>
<if test="vehicleReturnDate != null "> and a.vehicle_return_date = #{vehicleReturnDate}</if>
<if test="isDel != null and isDel != ''"> and a.is_del = #{isDel}</if>
</where>
order by a.vehicle_use_record_id desc
</select>
<select id="selectTVehicleUseRecordById" parameterType="Long" resultMap="TVehicleUseRecordResult">
<include refid="selectTVehicleUseRecordVo"/>
where vehicle_use_record_id = #{vehicleUseRecordId}
</select>
<insert id="insertTVehicleUseRecord" parameterType="TVehicleUseRecord" useGeneratedKeys="true" keyProperty="vehicleUseRecordId">
insert into t_vehicle_use_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="stationId != null">station_id,</if>
<if test="vehicleId != null">vehicle_id,</if>
<if test="vehicleUserId != null">vehicle_user_id,</if>
<if test="vehicleUseDate != null">vehicle_use_date,</if>
<if test="vehicleReturnDate != null">vehicle_return_date,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="isDel != null">is_del,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="stationId != null">#{stationId},</if>
<if test="vehicleId != null">#{vehicleId},</if>
<if test="vehicleUserId != null">#{vehicleUserId},</if>
<if test="vehicleUseDate != null">#{vehicleUseDate},</if>
<if test="vehicleReturnDate != null">#{vehicleReturnDate},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="isDel != null">#{isDel},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateTVehicleUseRecord" parameterType="TVehicleUseRecord">
update t_vehicle_use_record
<trim prefix="SET" suffixOverrides=",">
<if test="stationId != null">station_id = #{stationId},</if>
<if test="vehicleId != null">vehicle_id = #{vehicleId},</if>
<if test="vehicleUserId != null">vehicle_user_id = #{vehicleUserId},</if>
<if test="vehicleUseDate != null">vehicle_use_date = #{vehicleUseDate},</if>
<if test="vehicleReturnDate != null">vehicle_return_date = #{vehicleReturnDate},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="isDel != null">is_del = #{isDel},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where vehicle_use_record_id = #{vehicleUseRecordId}
</update>
<delete id="deleteTVehicleUseRecordById" parameterType="Long">
delete from t_vehicle_use_record where vehicle_use_record_id = #{vehicleUseRecordId}
</delete>
<delete id="deleteTVehicleUseRecordByIds" parameterType="String">
delete from t_vehicle_use_record where vehicle_use_record_id in
<foreach item="vehicleUseRecordId" collection="array" open="(" separator="," close=")">
#{vehicleUseRecordId}
</foreach>
</delete>
</mapper>
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