出行调整
This commit is contained in:
parent
d7e91a7faa
commit
327a2179aa
|
@ -261,6 +261,11 @@ public class Artificer implements Serializable {
|
|||
*/
|
||||
private Integer acceptOrders;
|
||||
|
||||
/**
|
||||
* 技师是否可调整出行方式 1是 2否
|
||||
*/
|
||||
private Integer adjustWay;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<ArtificerClassify> artificerClassifyList;
|
||||
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
package com.sqx.modules.traveladjust.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.traveladjust.entity.TravelAdjust;
|
||||
import com.sqx.modules.traveladjust.service.TravelAdjustService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author bai
|
||||
* @date 2024/06/08
|
||||
*/
|
||||
@RestController
|
||||
@Api(value = "出行管理", tags = { "出行管理" })
|
||||
@RequestMapping(value = "/travelAdjust")
|
||||
public class TravelAdjustController {
|
||||
|
||||
@Autowired
|
||||
private TravelAdjustService service;
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获取数据列表")
|
||||
public Result list(TravelAdjust entity, Integer page, Integer limit){
|
||||
QueryWrapper<TravelAdjust> qw = new QueryWrapper<>();
|
||||
IPage<TravelAdjust> pageList = service.page(new Page<>(page,limit),qw);
|
||||
return Result.success().put("data",pageList);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/add")
|
||||
@ApiOperation("新增")
|
||||
public Result add(@RequestBody TravelAdjust entity){
|
||||
entity.setCreateTime(DateUtil.now());
|
||||
entity.setUpdateTime(DateUtil.now());
|
||||
return Result.success().put("data",service.save(entity));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/update")
|
||||
@ApiOperation("修改")
|
||||
public Result update(@RequestBody TravelAdjust entity){
|
||||
entity.setUpdateTime(DateUtil.now());
|
||||
return Result.success().put("data",service.updateById(entity));
|
||||
}
|
||||
|
||||
@RequestMapping("/info/{id}")
|
||||
public Result info(@PathVariable("id") Long id){
|
||||
TravelAdjust data = service.getById(id);
|
||||
return Result.success().put("data", data);
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/deleteById")
|
||||
@ApiOperation("删除")
|
||||
public Result deleteById(Long id){
|
||||
service.removeById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/deleteByIds")
|
||||
@ApiOperation("批量删除")
|
||||
public Result deleteByIds(String id){
|
||||
if(StringUtils.isNotBlank(id)){
|
||||
String[] ids = StringUtils.split(id,",");
|
||||
service.removeByIds(Arrays.asList(ids));
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.sqx.modules.traveladjust.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.traveladjust.entity.TravelAdjust;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author bai
|
||||
* @date 2024/06/08
|
||||
*/
|
||||
@Mapper
|
||||
public interface TravelAdjustDao extends BaseMapper<TravelAdjust> {
|
||||
public TravelAdjust getTravelType(String businessTime);
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package com.sqx.modules.traveladjust.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author sentfan
|
||||
* @date 2025/03/17
|
||||
*/
|
||||
@ApiModel("出行调整")
|
||||
@Data
|
||||
@TableName("travel_adjust")
|
||||
public class TravelAdjust implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@ApiModelProperty("主键")
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ApiModelProperty("创建时间")
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@ApiModelProperty("修改时间")
|
||||
private String updateTime;
|
||||
|
||||
/**
|
||||
* 切换时间点1
|
||||
*/
|
||||
@ApiModelProperty("切换时间点1")
|
||||
private String pointTime1;
|
||||
|
||||
/**
|
||||
* 出行方式1(1:公交,2:出租,3:免费)
|
||||
*/
|
||||
@ApiModelProperty("出行方式(1:公交,2:出租,3:免费)")
|
||||
private Integer travelType1;
|
||||
|
||||
/**
|
||||
* 免费公里数1
|
||||
*/
|
||||
@ApiModelProperty("免费公里数1")
|
||||
private BigDecimal travelNum1;
|
||||
|
||||
/**
|
||||
* 切换时间点2
|
||||
*/
|
||||
@ApiModelProperty("切换时间点2")
|
||||
private String pointTime2;
|
||||
|
||||
/**
|
||||
* 出行方式2(1:公交,2:出租,3:免费)
|
||||
*/
|
||||
@ApiModelProperty("出行方式(1:公交,2:出租,3:免费)")
|
||||
private Integer travelType2;
|
||||
|
||||
/**
|
||||
* 免费公里数2
|
||||
*/
|
||||
@ApiModelProperty("免费公里数2")
|
||||
private BigDecimal travelNum2;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.sqx.modules.traveladjust.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.modules.traveladjust.entity.TravelAdjust;
|
||||
|
||||
public interface TravelAdjustService extends IService<TravelAdjust> {
|
||||
|
||||
/**
|
||||
* 获取出行方式
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
TravelAdjust getTravelType(String businessTime);
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.sqx.modules.traveladjust.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.modules.traveladjust.dao.TravelAdjustDao;
|
||||
import com.sqx.modules.traveladjust.entity.TravelAdjust;
|
||||
import com.sqx.modules.traveladjust.service.TravelAdjustService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 消息
|
||||
*/
|
||||
@Service
|
||||
public class TravelAdjustServiceImpl extends ServiceImpl<TravelAdjustDao, TravelAdjust> implements TravelAdjustService {
|
||||
|
||||
@Autowired
|
||||
TravelAdjustDao travelAdjustDao;
|
||||
|
||||
@Override
|
||||
public TravelAdjust getTravelType(String businessTime) {
|
||||
return travelAdjustDao.getTravelType(businessTime);
|
||||
}
|
||||
|
||||
}
|
|
@ -15,6 +15,8 @@ import com.sqx.modules.common.entity.CommonInfo;
|
|||
import com.sqx.modules.common.enums.CommonEnum;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import com.sqx.modules.common.utils.CommonConfigUtil;
|
||||
import com.sqx.modules.traveladjust.dao.TravelAdjustDao;
|
||||
import com.sqx.modules.traveladjust.entity.TravelAdjust;
|
||||
import com.sqx.modules.travelconf.dao.TravelConfDao;
|
||||
import com.sqx.modules.travelconf.entity.TravelConf;
|
||||
import com.sqx.modules.travelconf.enums.TravelEnum;
|
||||
|
@ -39,6 +41,9 @@ public class TravelConfServiceImpl extends ServiceImpl<TravelConfDao, TravelConf
|
|||
@Autowired
|
||||
private ArtificerService artificerService;
|
||||
|
||||
@Autowired
|
||||
TravelAdjustDao travelAdjustDao;
|
||||
|
||||
@Override
|
||||
public TravelConf getConfByAccordingCondition(Integer travelType, Date businessTime) {
|
||||
//为空则使用当前系统时间
|
||||
|
@ -207,9 +212,18 @@ public class TravelConfServiceImpl extends ServiceImpl<TravelConfDao, TravelConf
|
|||
@Override
|
||||
public TravelPriceVo calcTravelPrice(Long artificerId, String toLongitude, String toLatitude, String serveTime) {
|
||||
Artificer artificerInfo = artificerService.getById(artificerId);
|
||||
|
||||
Integer cxfs = artificerInfo.getTripWay();//1公交 2出租 3免费
|
||||
BigDecimal mfgls = artificerInfo.getTripWayNum();//免费公里数
|
||||
Integer cxfs = 0;
|
||||
BigDecimal mfgls = BigDecimal.ZERO;
|
||||
//根据时间点判断出行方式
|
||||
if(artificerInfo.getAdjustWay() == 2){
|
||||
String businessTime = DateUtils.format(DateUtils.stringToDate(serveTime,"yyyy-MM-dd HH:mm"),"HH:mm:ss");
|
||||
TravelAdjust travelAdjust = travelAdjustDao.getTravelType(businessTime);
|
||||
cxfs = travelAdjust.getTravelType1();//1公交 2出租 3免费
|
||||
mfgls = travelAdjust.getTravelNum1();//免费公里数
|
||||
}else{
|
||||
cxfs = artificerInfo.getTripWay();//1公交 2出租 3免费
|
||||
mfgls = artificerInfo.getTripWayNum();//免费公里数
|
||||
}
|
||||
if(cxfs==null){
|
||||
cxfs = 3;
|
||||
}
|
||||
|
@ -227,7 +241,14 @@ public class TravelConfServiceImpl extends ServiceImpl<TravelConfDao, TravelConf
|
|||
@Override
|
||||
public TravelPriceVo calcTravelPrice(Long artificerId, String toLongitude, String toLatitude, String serveTime, Integer tripWay){
|
||||
Artificer artificerInfo = artificerService.getById(artificerId);
|
||||
BigDecimal mfgls = artificerInfo.getTripWayNum();//免费公里数
|
||||
BigDecimal mfgls = BigDecimal.ZERO;
|
||||
if(artificerInfo.getAdjustWay() == 2){
|
||||
String businessTime = DateUtils.format(DateUtils.stringToDate(serveTime,"yyyy-MM-dd HH:mm"),"HH:mm:ss");
|
||||
TravelAdjust travelAdjust = travelAdjustDao.getTravelType(businessTime);
|
||||
mfgls = travelAdjust.getTravelNum1();//免费公里数
|
||||
}else{
|
||||
mfgls = artificerInfo.getTripWayNum();//免费公里数
|
||||
}
|
||||
if(mfgls == null){
|
||||
mfgls = BigDecimal.ZERO;
|
||||
}
|
||||
|
@ -243,7 +264,7 @@ public class TravelConfServiceImpl extends ServiceImpl<TravelConfDao, TravelConf
|
|||
vo.setFreeKilometers(NumberUtil.decimalFormat("0.00",freeKilometers));
|
||||
|
||||
// Date now = DateTime.now();
|
||||
DateUtils.stringToDate(serveTime,"yyyy-MM-dd HH:mm");
|
||||
// DateUtils.stringToDate(serveTime,"yyyy-MM-dd HH:mm");
|
||||
Date now = DateUtils.stringToDate(serveTime,"yyyy-MM-dd HH:mm");;
|
||||
//按条件取配置,
|
||||
TravelConf conf = getConfByAccordingCondition(_travelType, now);
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<?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.sqx.modules.traveladjust.dao.TravelAdjustDao">
|
||||
|
||||
<select id="getTravelType" resultType="com.sqx.modules.traveladjust.entity.TravelAdjust">
|
||||
select
|
||||
point_time1 as pointTime1,
|
||||
travel_type1 as travelType1,
|
||||
travel_num1 as travelNum1
|
||||
from travel_adjust
|
||||
where point_time1 <= #{businessTime}
|
||||
and point_time2 > #{businessTime}
|
||||
union
|
||||
select
|
||||
point_time2 as pointTime1,
|
||||
travel_type2 as travelType1,
|
||||
travel_num2 as travelNum1
|
||||
from travel_adjust
|
||||
where point_time1 > #{businessTime}
|
||||
or point_time2 <= #{businessTime}
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue