8 changed files with 160 additions and 15 deletions
@ -0,0 +1,43 @@ |
|||
package com.ccsens.logistics.api; |
|||
|
|||
import com.ccsens.logistics.bean.dto.CarRecordDto; |
|||
import com.ccsens.logistics.bean.dto.MbpsDto; |
|||
import com.ccsens.logistics.bean.vo.MbpsVo; |
|||
import com.ccsens.logistics.service.ICarRecordService; |
|||
import com.ccsens.util.JsonResponse; |
|||
import com.ccsens.util.bean.dto.QueryDto; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import io.swagger.annotations.ApiParam; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import javax.annotation.Resource; |
|||
|
|||
/** |
|||
* @author 马 |
|||
*/ |
|||
|
|||
@Slf4j |
|||
@Api(tags = "车辆记录相关接口") |
|||
@RestController |
|||
@RequestMapping("/carRecord") |
|||
public class CarRecordController { |
|||
|
|||
@Resource |
|||
private ICarRecordService iCarRecordService; |
|||
|
|||
@ApiOperation(value = "添加车辆记录", notes = "mz:添加车辆记录") |
|||
@RequestMapping(value = "/addCarRecord", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse addCarRecord(@ApiParam @Validated @RequestBody QueryDto<CarRecordDto.AddCarRecord> params) { |
|||
log.info("添加车辆记录:{}",params); |
|||
iCarRecordService.addCarRecord(params.getParam()); |
|||
log.info("添加车辆记录:{}"); |
|||
return JsonResponse.newInstance().ok(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,28 @@ |
|||
package com.ccsens.logistics.bean.dto; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author 马 |
|||
*/ |
|||
@Data |
|||
public class CarRecordDto { |
|||
|
|||
@Data |
|||
@ApiModel(value = "手动添加车辆记录") |
|||
public static class AddCarRecord{ |
|||
@ApiModelProperty("记录时间") |
|||
private Long recordTime; |
|||
@ApiModelProperty("车型(0-小型车,1-中型车,2-大型车)") |
|||
private Byte carType; |
|||
@ApiModelProperty("进出类型(0-进,1-出)") |
|||
private Byte inOut; |
|||
@ApiModelProperty("车牌号") |
|||
private String licensePlate; |
|||
@ApiModelProperty("车辆重量") |
|||
private Long carWeight; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,10 @@ |
|||
package com.ccsens.logistics.bean.vo; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author 马 |
|||
*/ |
|||
@Data |
|||
public class CarRecordVo { |
|||
} |
@ -0,0 +1,53 @@ |
|||
package com.ccsens.logistics.service; |
|||
|
|||
import cn.hutool.core.lang.Snowflake; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import com.ccsens.logistics.bean.dto.CarRecordDto; |
|||
import com.ccsens.logistics.bean.po.LogisticsCarRecord; |
|||
import com.ccsens.logistics.persist.dao.LogisticsCarRecordDao; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Propagation; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import javax.annotation.Resource; |
|||
|
|||
/** |
|||
* @author 马 |
|||
*/ |
|||
|
|||
@Slf4j |
|||
@Service |
|||
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class) |
|||
public class CarRecordService implements ICarRecordService { |
|||
|
|||
@Resource |
|||
private Snowflake snowflake; |
|||
@Resource |
|||
private LogisticsCarRecordDao carRecordDao; |
|||
|
|||
@Override |
|||
public void addCarRecord(CarRecordDto.AddCarRecord param) { |
|||
LogisticsCarRecord carRecord = new LogisticsCarRecord(); |
|||
carRecord.setId(snowflake.nextId()); |
|||
//车辆类型
|
|||
carRecord.setCarType(param.getCarType()); |
|||
//记录时间
|
|||
carRecord.setRecordTime(param.getRecordTime()); |
|||
//进出类型
|
|||
carRecord.setInOut(param.getInOut()); |
|||
//车牌
|
|||
if (StrUtil.isNotBlank(param.getLicensePlate())){ |
|||
carRecord.setLicensePlate(param.getLicensePlate()); |
|||
}else{ |
|||
carRecord.setLicensePlate("未知"); |
|||
} |
|||
//车辆重量
|
|||
if (null != param.getCarWeight()){ |
|||
carRecord.setCarWeight(param.getCarWeight()); |
|||
} |
|||
|
|||
carRecordDao.insertSelective(carRecord); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,15 @@ |
|||
package com.ccsens.logistics.service; |
|||
|
|||
import com.ccsens.logistics.bean.dto.CarRecordDto; |
|||
|
|||
/** |
|||
* @author 马 |
|||
*/ |
|||
|
|||
public interface ICarRecordService { |
|||
/** |
|||
* 手动添加车辆记录 |
|||
* @param param 车辆类型 记录时间 |
|||
*/ |
|||
void addCarRecord(CarRecordDto.AddCarRecord param); |
|||
} |
Loading…
Reference in new issue