Commit b9d55308 authored by hezhen's avatar hezhen

123

parent 3d543d0e
package com.xxfc.platform.vehicle.pojo.dto;
import com.github.wxiaoqi.security.common.constant.CommonConstants;
import com.github.wxiaoqi.security.common.vo.DataInter;
import com.github.wxiaoqi.security.common.vo.PageParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.List;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.YMR_SLASH_FORMATTER;
/**
* @author libin
* @version 1.0
......@@ -17,6 +25,8 @@ import java.util.List;
@Data
public class VehicleFindDTO extends PageParam implements DataInter {
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
@ApiModelProperty("商品Id")
private String vehicleId;
......@@ -59,4 +69,51 @@ public class VehicleFindDTO extends PageParam implements DataInter {
@ApiModelProperty("店铺状态:1-上架中;2-下架中;3-已调出")
private Integer goodStatus;
/**
* 预定目标日期(开始)
*/
@ApiModelProperty("目标日期(开始)")
private String bookStartDate;
/**
* 预定目标日期(结束)
*/
@ApiModelProperty("目标日期(结束)")
private String bookEndDate;
/**
* 预定目标日期(开始)
*/
@ApiModelProperty("目标时间(开始)")
private String bookStartDateTime;
/**
* 预定目标日期(结束)
*/
@ApiModelProperty("目标时间(结束)")
private String bookEndDateTime;
@ApiModelProperty("开始时间戳")
Long startDateTamp;
@ApiModelProperty("结束时间戳")
Long endDateTamp;
public void setStartDateTamp(Long startDateTamp) {
this.startDateTamp = startDateTamp;
this.bookStartDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startDateTamp), ZoneOffset.ofHours(8)));
this.bookStartDateTime = CommonConstants.DATE_TIME_LINE_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startDateTamp), ZoneOffset.ofHours(8)));
}
public void setEndDateTamp(Long endDateTamp) {
this.endDateTamp = endDateTamp;
this.bookEndDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(endDateTamp), ZoneOffset.ofHours(8)));
this.bookEndDateTime = CommonConstants.DATE_TIME_LINE_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(endDateTamp), ZoneOffset.ofHours(8)));
}
}
......@@ -1671,6 +1671,23 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return mapper.selectList(vehicleFindDTO);
}
public List<VehicleVO> getListV2(VehicleFindDTO vehicleFindDTO){
Map<String, Object> map = setBookDate(vehicleFindDTO);
return mapper.selectListV2(map);
}
public ObjectRestResponse selectListV2(VehicleFindDTO vehicleFindDTO){
PageDataVO<VehicleVO> dataVo = PageDataVO.pageInfo(vehicleFindDTO.initQuery(),()-> getListV2(vehicleFindDTO));
List<VehicleVO> list = dataVo.getData();
if(list != null && list.size() > 0){
for (VehicleVO vehicleVO : list){
vehicleVO.setExtensionVOS(extensionBiz.getTree(vehicleVO.getId()));
}
}
return ObjectRestResponse.succ(dataVo);
}
public ObjectRestResponse selectList(VehicleFindDTO vehicleFindDTO){
Integer type=vehicleFindDTO.getType() == null ? 0 :vehicleFindDTO.getType();
if (type > 0){
......@@ -1814,6 +1831,32 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return ObjectRestResponse.succ();
}
public Map<String, Object> setBookDate(VehicleFindDTO dto){
List<String> notBookedDates = Lists.newArrayList();
if (StringUtils.isNotBlank(dto.getBookEndDate()) &&
StringUtils.isNotBlank(dto.getBookEndDate())) {
notBookedDates = convertDatePeriod2List(dto.getBookStartDate(),
dto.getBookEndDate());
}
Map<String, Object> params = BeanUtil.beanToMap(dto);
//若传入预定信息查询条件,则查询对应月份预定信息查询条件(不超过3个月)
if (CollectionUtils.isEmpty(notBookedDates)) {
//return;
}
//筛选出查询条件所在月份
Set<String> allYearMonth = new HashSet<>();//记录所有年月
Map<String, List<String>> yearMonthAndDate = new HashMap<>();//预定年月 - 预定日期列表
Map<String, List<String>> yearMonthAndDateNotBooked = new HashMap<>();//未预定年月 - 未预定日期列表
classifyByYearMonth(notBookedDates, yearMonthAndDateNotBooked, allYearMonth);
if (allYearMonth.size() > MAX_MONTH_COUNT_BOOKED_INFO_QUERY) {
throw new BaseException(" only 3 month can be included <bookedInfo> param.");
}
//加入预定信息查询条件
fillBookedDateSearchParam(params, yearMonthAndDate, yearMonthAndDateNotBooked);
return params;
}
......
......@@ -65,6 +65,8 @@ public interface VehicleMapper extends Mapper<Vehicle> {
List<VehicleVO> selectList(VehicleFindDTO vehicleFindDTO);
List<VehicleVO> selectListV2(Map<String, Object> param);
@Select("SELECT COUNT(*) FROM vehicle WHERE is_del=0 and subordinate_branch = #{commpanyId}")
Long countByCompamyId(@Param("commpanyId") Integer commpanyId);
......
......@@ -41,6 +41,19 @@ public class AppVehicleController extends BaseController<VehicleBiz> {
}
@GetMapping("selectListV2")
@ApiModelProperty("商品列表")
public ObjectRestResponse selectListV2(VehicleFindDTO vehicleFindDTO) {
if (vehicleFindDTO.getBranchId() == null || vehicleFindDTO.getBranchId() == 0){
List<Integer> companyIds = getBusinessUserCompanyIds();
if (companyIds != null && companyIds.size() > 0){
vehicleFindDTO.setBranchId(companyIds.get(0));
}
}
return baseBiz.selectListV2(vehicleFindDTO);
}
@PostMapping("updVehicle")
@ApiModelProperty("更新商品信息")
public ObjectRestResponse updVehicle(@RequestBody Vehicle vehicle) {
......
......@@ -1455,6 +1455,67 @@
</select>
<select id="selectListV2" resultType="com.xxfc.platform.vehicle.pojo.vo.VehicleVO" parameterType="java.util.Map">
SELECT
v.*,
b.cn_name as brandName,
c.`name` categoryName
FROM ( <include refid="searchUsableSqlV2"/> ) v
LEFT JOIN (select * from vehicle_use_time where status =1 ) u ON v.id = u.vehicle_id
LEFT JOIN vehicle_brand b ON v.brand_id=b.id
LEFT JOIN vehicle_category c ON v.category_id=c.id
<where>
v.is_del = 0 and u.id is null
<if test="goodsType != null ">
AND v.`goods_type`= #{goodsType}
</if>
<if test="branchId != null and branchId > 0">
AND (v.`subordinate_branch`= #{branchId} AND v.`manage_company_id`= #{branchId} )
</if>
</where>
ORDER BY v.create_time DESC
</select>
<sql id="searchUsableSqlV2">
select * from vehicle v
<if test=" yearMonthAndParam !=null ">
left join (
select
vbi.vehicle,
BIT_OR(
CONCAT(
<foreach collection="yearMonthAndParam" index="yearMonth" item="andOperation" separator=",">
<include refid="yearMonthAndParamSql"></include>
</foreach>
)
) as bit_str
from vehicle_book_info vbi group by vbi.vehicle
) vbi on v.`id` = vbi.vehicle
</if>
<!-- <if test="startCompanyId != null and endCompanyId != null ">-->
<!--
* 原(大于预约结束时间,小于预约开始时间的预约记录)
* 相交叉(大于预约开始时间,小于预约结束时间的预约记录)
-->
<where>
v.is_del = 0
<!-- 若需根据预定日期条件查询,针对换为位操作 -->
<!-- yearNo4Where 标识时间参数是否用于where条件 -->
<if test=" yearMonthAndParam !=null and yearMonthAndParam != null and (yearNo4Where == null or yearNo4Where != true)">
and vbi.bit_str = #{yearMonthAndParamBitStr}
</if>
<if test=" yearNo4Where != null and recordIntersection != null and recordIntersection == true">
<!-- 1、最后还车时间(天) 大于 最早提车时间(天) 并且多于一天-->
and if((abr.to_lift_must_after_date is null or abr.to_return_must_before_date is null), true
, (str_to_date(DATE_FORMAT(abr.to_return_must_before_date,'%Y-%m-%d'),'%Y-%m-%d %H:%i:%s')
> DATE_ADD(DATE_ADD(str_to_date(DATE_FORMAT(abr.to_lift_must_after_date,'%Y-%m-%d'),'%Y-%m-%d %H:%i:%s'),INTERVAL 2 DAY),INTERVAL -1 SECOND))
)
</if>
</where>
</sql>
<select id="appSelectList" resultType="com.xxfc.platform.vehicle.pojo.vo.VehicleVO" parameterType="com.xxfc.platform.vehicle.pojo.dto.VehicleFindAppDTO">
SELECT
v.*,
......
......@@ -21,7 +21,7 @@
AND p.`goods_type`= #{goodsType}
</if>
<if test="nowTime != null and nowTime > 0">
AND p.`publish_end_time` >= #{nowTime}
AND p.`publish_end_time` >= #{nowTime} AND p.number > (p.confirm_number+p.wait_confirm_number)
</if>
<if test="dataCompanyIds != null and dataCompanyIds.size > 0">
and p.id in
......
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