@ -3,14 +3,23 @@ package com.zhehekeji.web.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.github.pagehelper.PageHelper ;
import com.github.pagehelper.PageInfo ;
import com.zhehekeji.web.config.ConfigProperties ;
import com.zhehekeji.web.entity.CheckLog ;
import com.zhehekeji.web.entity.Street ;
import com.zhehekeji.web.mapper.CheckLogMapper ;
import com.zhehekeji.web.pojo.CheckLogOne ;
import com.zhehekeji.web.pojo.Obg ;
import com.zhehekeji.web.pojo.stock.CheckLogSearch ;
import com.zhehekeji.web.pojo.street.StreetVO ;
import org.springframework.stereotype.Service ;
import org.springframework.util.StringUtils ;
import javax.annotation.Resource ;
import java.time.LocalDate ;
import java.time.LocalDateTime ;
import java.time.LocalTime ;
import java.time.format.DateTimeFormatter ;
import java.util.ArrayList ;
import java.util.HashMap ;
import java.util.List ;
import java.util.Map ;
@ -23,6 +32,9 @@ public class CheckLogService {
@Resource
private StreetService streetService ;
@Resource
private ConfigProperties configProperties ;
public PageInfo < CheckLog > list ( CheckLogSearch search ) {
List < StreetVO > list = streetService . list ( ) ;
Map < Integer , String > map = new HashMap < > ( ) ;
@ -59,4 +71,63 @@ public class CheckLogService {
} ) ;
return new PageInfo < > ( stockChecks ) ;
}
public Obg < CheckLogOne > getOne ( Obg < CheckLogSearch > checkLogSearch ) {
Obg < CheckLogOne > obg = new Obg < > ( ) ;
List < CheckLogOne > checkLogOnes = new ArrayList < > ( ) ;
for ( CheckLogSearch search : checkLogSearch . getData ( ) ) {
CheckLogOne checkLogOne = new CheckLogOne ( ) ;
search . getLocInfo ( ) ;
Street streetVO = streetService . getStreetByPlcId ( search . getStreetPlc ( ) ) ;
// 定义日期格式
DateTimeFormatter formatter = DateTimeFormatter . ofPattern ( "yyyy-MM-dd" ) ;
// 将字符串转换为LocalDate对象
LocalDate specifiedDate = LocalDate . parse ( search . getDate ( ) , formatter ) ;
// 获取指定日期的开始时间和结束时间
// 生成当天最早时间
LocalDateTime dateStart = specifiedDate . atStartOfDay ( ) ;
// 生成当天最晚时间
LocalDateTime dateEnd = specifiedDate . atTime ( 23 , 59 , 59 ) ;
CheckLog checkLog = checkLogMapper . selectOne ( new QueryWrapper < CheckLog > ( )
. eq ( search . getJobnum ( ) ! = null , "check_num" , search . getStreetPlc ( ) + "_" + search . getJobnum ( ) )
. eq ( streetVO . getId ( ) ! = null , "street_id" , streetVO . getId ( ) )
. eq ( search . getRow ( ) ! = null , "`row`" , search . getRow ( ) )
. eq ( search . getColumn ( ) ! = null , "`column`" , search . getColumn ( ) )
. between ( "create_time" , dateStart , dateEnd )
. eq ( search . getLeftRight ( ) ! = null , "direction" , search . getLeftRight ( ) )
. orderByDesc ( "create_time" )
. last ( "limit 1" )
) ;
checkLogOne . setLoc ( search . getLoc ( ) ) ;
checkLogOne . setFlag ( "false" ) ;
checkLogOne . setFrom_tagid ( search . getTagid ( ) ) ;
if ( checkLog ! = null ) {
checkLogOne . setJobnum ( checkLog . getCheckNum ( ) . split ( "_" ) [ 1 ] ) ;
//图片
checkLogOne . setPicture_routesid ( configProperties . getPicIpPort ( ) + checkLog . getPic ( ) ) ;
if ( checkLog . getStatus ( ) ! = 1 ) {
checkLogOne . setFlag ( "true" ) ;
checkLogOne . setTo_tagid ( search . getTagid ( ) ) ;
}
}
checkLogOnes . add ( checkLogOne ) ;
}
obg . setData ( checkLogOnes ) ;
return obg ;
}
public static void main ( String [ ] args ) {
System . out . println ( "001_21316" ) ;
}
}