package com.sandu.ximon.admin.security;
|
|
import com.sandu.ximon.admin.service.LampCountService;
|
import com.sandu.ximon.dao.domain.LampCount;
|
import lombok.AllArgsConstructor;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Component;
|
|
import java.text.DateFormat;
|
import java.text.SimpleDateFormat;
|
import java.util.Calendar;
|
|
@Component
|
@Slf4j
|
@AllArgsConstructor
|
@EnableScheduling
|
public class CountSet {
|
private final LampCountService lampCountService;
|
public String aVoid() {
|
//LampCount one = getOne(Wrappers.lambdaQuery(LampCount.class));//
|
LampCount one= lampCountService.list().get(0);
|
int count=one.getCount();
|
String number =null;
|
DateFormat df = new SimpleDateFormat("yy");
|
DateFormat df1 = new SimpleDateFormat("MM");
|
DateFormat df2 = new SimpleDateFormat("dd");
|
String formattedDate = df.format(Calendar.getInstance().getTime());
|
String formattedDate1 = df1.format(Calendar.getInstance().getTime());
|
String formattedDate2 = df2.format(Calendar.getInstance().getTime());
|
if(count<10){
|
number="000"+count;
|
}else if(count>10&&count<100){
|
number="00"+count;
|
}else if(count>100&&count<1000){
|
number="0"+count;
|
}
|
// formattedDate+formattedDate1+formattedDate2+count
|
System.out.println(formattedDate+formattedDate1+formattedDate2+number);
|
|
count++;
|
one.setCount(count);
|
lampCountService.updateById(one);
|
|
return formattedDate+formattedDate1+formattedDate2+number;
|
|
}
|
@Scheduled(cron = "0 0 0 * * ?")
|
public void reset(){
|
//LampCount one = getOne(Wrappers.lambdaQuery(LampCount.class));
|
LampCount one= lampCountService.list().get(0);
|
one.setCount(4);
|
lampCountService.updateById(one);
|
}
|
}
|