修改线路模板具体信息接口,没有当前月数据时使用最新数据的所在月数据

main
吴顺杰 2 weeks ago
parent f6e9cbd9c7
commit c23c4ef470

@ -10,6 +10,7 @@ import com.ykMap.entity.response.UserInfoResponse;
import org.apache.ibatis.annotations.Param;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
/**
@ -58,4 +59,10 @@ public interface LineMapper{
SearchCityCountResponse searchCityCount(@Param("a1") LocalDate a1, @Param("a2")LocalDate a2);
String getByCarId(String id);
/**
*
* @return
*/
LocalDateTime findLineTemplateTime();
}

@ -1,6 +1,7 @@
package com.ykMap.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.ykMap.entity.response.EquipResponse;
import com.ykMap.entity.response.GetCarIdInfoResponse;
import com.ykMap.entity.response.ItemsResponse;
@ -15,6 +16,8 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.TemporalAdjusters;
import java.util.List;
/**
@ -66,16 +69,30 @@ public class LineServiceImpl implements LineService {
*/
@Override
public List<LineTemplateResponse> lineTemplate(String area) {
List<LineTemplateResponse> list;
LocalDate now = LocalDate.now();
if (now.getDayOfMonth() < 26) {
LocalDate a1 = now.minusMonths(2).withDayOfMonth(26);
LocalDate a2 = now.minusMonths(1).withDayOfMonth(25);
return lineMapper.lineTemplate(area, a1, a2);
list = lineMapper.lineTemplate(area, a1, a2);
} else {
LocalDate a1 = now.minusMonths(1).withDayOfMonth(26);
LocalDate a2 = now.withDayOfMonth(25);
return lineMapper.lineTemplate(area, a1, a2);
list = lineMapper.lineTemplate(area, a1, a2);
}
if (CollectionUtil.isEmpty(list)) {
// 查询数据库最新时间
LocalDateTime dataTime = lineMapper.findLineTemplateTime();
if (dataTime == null) {
return null;
}
// 获取数据库最新时间月份的第一天
LocalDate firstDayOfMonth = dataTime.with(TemporalAdjusters.firstDayOfMonth()).toLocalDate();
// 获取数据库最新时间月份的最后一天
LocalDate lastDayOfMonth = dataTime.with(TemporalAdjusters.lastDayOfMonth()).toLocalDate();
list = lineMapper.lineTemplate(area, firstDayOfMonth, lastDayOfMonth);
}
return list;
}
/**

@ -72,4 +72,11 @@
from task_mission_thing where vehicle_id = #{id}
</select>
<select id="findLineTemplateTime" resultType="java.time.LocalDateTime">
select data_time
from ysk_ywbmwjdr.operation_overview_data
order by data_time desc
limit 1
</select>
</mapper>

Loading…
Cancel
Save