Commit c466ca77 authored by hezhen's avatar hezhen

添加占用

parent f02bf510
package com.xxfc.platform.vehicle.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
/**
* 车辆预定占用
*
* @author zjw
* @email nishijjo@qq.com
* @date 2019-05-25 10:13:57
*/
@Data
@Table(name = "vehicle_record_employ")
public class VehicleRecordEmploy implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("主键id")
private Long id;
@Column(name = "company_id")
@ApiModelProperty(value = "经营公司id")
private Integer companyId;
@Column(name = "vehicle_id")
@ApiModelProperty(value = "预定id")
private String vehicleId;
@Column(name = "book_record_id")
@ApiModelProperty(value = "店铺id")
private Long bookRecordId;
@Column(name = "start_time")
@ApiModelProperty(value = "开始时间")
private Long startTime;
@Column(name = "end_time")
@ApiModelProperty(value = "结束时间")
private Long endTime;
@Column(name = "status")
@ApiModelProperty(value = "状态:1-启用;2-禁用")
private Integer status;
@Column(name = "crt_time")
@ApiModelProperty(value = "创建时间", hidden = true )
private Long crtTime;
@Column(name = "upd_time")
@ApiModelProperty(value = "更新时间", hidden = true )
private Long updTime;
@Column(name = "is_del")
@ApiModelProperty(value = "是否删除:0-正常;1-删除")
private Integer isDel;
}
package com.xxfc.platform.vehicle.pojo.dto;
import com.xxfc.platform.vehicle.entity.VehicleRecordEmploy;
import io.swagger.annotations.ApiModelProperty;
import java.text.SimpleDateFormat;
import java.util.Date;
public class VehicleRecordEmployDTO extends VehicleRecordEmploy {
private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ApiModelProperty("预定目标日期(开始) yyyy-MM-dd HH:mm:ss")
private String bookStartDate;
/**
* 预定目标日期(结束)
*/
@ApiModelProperty("预定目标日期(结束) yyyy-MM-dd HH:mm:ss")
private String bookEndDate;
public String getBookStartDate(){
String bookStartDate = null;
if (this.getStartTime() != null && this.getStartTime() > 0){
try {
bookStartDate = dateFormat.format(new Date(this.getStartTime()));
}catch (Exception e){
}
}
return bookStartDate;
}
public String getBookEndDate(){
String bookEndDate = null;
if (this.getEndTime() != null && this.getEndTime() > 0){
try {
bookEndDate = dateFormat.format(new Date(this.getEndTime()));
}catch (Exception e){
}
}
return bookEndDate;
}
}
......@@ -2,6 +2,7 @@ package com.xxfc.platform.vehicle.pojo.vo;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.entity.VehicleApply;
import com.xxfc.platform.vehicle.entity.VehicleRecordEmploy;
import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -75,4 +76,6 @@ public class VehicleVO extends Vehicle {
private String manageCityName;
private VehicleRecordEmploy recordEmploy;
}
\ No newline at end of file
......@@ -131,6 +131,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
@Autowired
VehicleCategoryBiz vehicleCategoryBiz;
@Autowired
VehicleRecordEmployBiz recordEmployBiz;
@Override
public UserFeign getUserFeign() {
return userFeign;
......@@ -1758,7 +1761,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
}
handleOption.put("update", true);// 编辑操作
}
vehicleVO.setRecordEmploy(recordEmployBiz.getInfo(vehicleId));
}else if (type == 3){
//类型是申请经营并且申请公司是停靠公司
if (vehicleManageApply !=null && vehicleManageApply.getApplyId().equals(parkBranchCompanyId) && vehicleManageApply.getType() == 1){
......
package com.xxfc.platform.vehicle.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.context.BaseContextHandler;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus;
import com.xxfc.platform.vehicle.entity.*;
import com.xxfc.platform.vehicle.mapper.VehicleRecordEmployMapper;
import com.xxfc.platform.vehicle.pojo.BookVehicleVO;
import com.xxfc.platform.vehicle.pojo.dto.VehicleRecordEmployDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
@Service
@Slf4j
public class VehicleRecordEmployBiz extends BaseBiz<VehicleRecordEmployMapper, VehicleRecordEmploy> {
@Autowired
VehicleBiz vehicleBiz;
@Autowired
BranchCompanyBiz branchCompanyBiz;
public void addOrUpd(VehicleRecordEmployDTO recordEmployDTO) throws Exception{
String vehicleId = recordEmployDTO.getVehicleId();
if (StringUtils.isBlank(vehicleId) ){
throw new BaseException("参数不能为空", ResultCode.FAILED_CODE);
}
Integer status = recordEmployDTO.getStatus() == null ? 1 : recordEmployDTO.getStatus();
VehicleRecordEmploy vehicleRecordEmploy = new VehicleRecordEmployDTO();
BeanUtils.copyProperties(recordEmployDTO,vehicleRecordEmploy);
VehicleRecordEmploy vehicleRecordEmploy1 = getInfo(vehicleId);
if (vehicleRecordEmploy1 != null){
Long bookRecordId = vehicleRecordEmploy1.getBookRecordId() == null ? 0L : vehicleRecordEmploy1.getBookRecordId();
if (bookRecordId > 0L){
if (vehicleRecordEmploy1.getStatus() == 1)
canelRecord(bookRecordId);
if (status == 1){
bookRecordId = addRecord(recordEmployDTO);
}
}
vehicleRecordEmploy.setStatus(status);
vehicleRecordEmploy.setBookRecordId(bookRecordId);
vehicleRecordEmploy.setId(vehicleRecordEmploy1.getId());
updateSelectiveById(vehicleRecordEmploy);
}else {
Long bookRecordId = addRecord(recordEmployDTO);
vehicleRecordEmploy.setBookRecordId(bookRecordId);
insertSelective(vehicleRecordEmploy);
}
}
//车辆预定
public Long addRecord(VehicleRecordEmployDTO recordEmployDTO) throws Exception{
Integer companyId = recordEmployDTO.getCompanyId() == null ? 0 :recordEmployDTO.getCompanyId();
BranchCompany branchCompany = branchCompanyBiz.selectById(companyId);
if (branchCompany == null)
throw new BaseException("公司不能为空", ResultCode.FAILED_CODE);
BookVehicleVO bookVehicleVo = new BookVehicleVO();
BeanUtils.copyProperties(recordEmployDTO,bookVehicleVo);
Integer operatorId = Integer.parseInt(BaseContextHandler.getUserID());
String userName = BaseContextHandler.getName();
bookVehicleVo.setBookType(4);
bookVehicleVo.setStatus(VehicleBookRecordStatus.APPROVE.getCode());
bookVehicleVo.setNotCheckTimeLegal(Boolean.FALSE);
bookVehicleVo.setVehicleUsername(branchCompany.getLeader());
bookVehicleVo.setVehicleUserPhone(branchCompany.getLeaderContactInfo());
bookVehicleVo.setRetCompany(companyId);
VehicleBookRecord vehicleBookRecord = vehicleBiz.applyVehicle(operatorId, bookVehicleVo, userName);
if (vehicleBookRecord == null )
throw new BaseException("公司不能为空", ResultCode.FAILED_CODE);
return vehicleBookRecord.getId();
}
//取消预定
public void canelRecord(Long bookRecordI) throws Exception{
Integer operatorId = Integer.parseInt(BaseContextHandler.getUserID());
String userName = BaseContextHandler.getName();
RestResponse restResponse = vehicleBiz.unbookVehicle4Employee(operatorId, bookRecordI, userName, null, Boolean.FALSE);
if (!restResponse.getCode().equals(RestResponse.suc().getCode()))
throw new BaseException("取消失败", ResultCode.FAILED_CODE);
}
public VehicleRecordEmploy getInfo(String vehicleId){
Example example = new Example(VehicleRecordEmploy.class);
example.createCriteria().andEqualTo("vehicleId",vehicleId).andEqualTo("isDel" , 0);
List<VehicleRecordEmploy> list = selectByExample(example);
if (list.size() > 0)
return list.get(0);
return null;
}
}
package com.xxfc.platform.vehicle.mapper;
import com.xxfc.platform.vehicle.entity.VehicleRecordEmploy;
import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper;
import tk.mybatis.mapper.common.Mapper;
public interface VehicleRecordEmployMapper extends Mapper<VehicleRecordEmploy>, SelectByIdListMapper<VehicleRecordEmploy,Integer> {
}
\ No newline at end of file
package com.xxfc.platform.vehicle.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.vehicle.biz.VehicleRecordEmployBiz;
import com.xxfc.platform.vehicle.pojo.dto.VehicleRecordEmployDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author Administrator
*/
@Slf4j
@RestController
@RequestMapping("app/vehicleRecord")
@Api(tags = {"车辆预定占用"})
public class AppVehicleRecordEmployController extends BaseController<VehicleRecordEmployBiz> {
@PostMapping("addOrUpd")
@ApiModelProperty("更新")
public ObjectRestResponse updVehicle(@RequestBody VehicleRecordEmployDTO vehicleRecordEmployDTO) throws Exception{
if (vehicleRecordEmployDTO.getCompanyId() == null || vehicleRecordEmployDTO.getCompanyId() == 0){
List<Integer> companyIds = getBusinessUserCompanyIds();
if (companyIds != null && companyIds.size() > 0){
vehicleRecordEmployDTO.setCompanyId(companyIds.get(0));
}
}
baseBiz.addOrUpd(vehicleRecordEmployDTO);
return ObjectRestResponse.succ();
}
@GetMapping("info/{vehicelId}")
@ApiModelProperty("详情")
public ObjectRestResponse info(@PathVariable(value = "vehicelId") String vehicelId) {
return ObjectRestResponse.succ(baseBiz.getInfo(vehicelId));
}
}
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