package com.sandu.ximon.admin.security;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.sandu.common.service.impl.BaseServiceImpl;
|
import com.sandu.ximon.dao.domain.LampCount;
|
import com.sandu.ximon.dao.mapper.LampCountMapper;
|
import lombok.AllArgsConstructor;
|
import lombok.Data;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Component;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.text.DateFormat;
|
import java.text.SimpleDateFormat;
|
import java.time.LocalDateTime;
|
import java.util.Calendar;
|
import java.util.Date;
|
|
@Component
|
@Slf4j
|
@AllArgsConstructor
|
@RestController
|
@RequestMapping("aaa")
|
@EnableScheduling
|
public class CountSet extends BaseServiceImpl<LampCountMapper,LampCount> {
|
public String aVoid() {
|
LampCount one = getOne(Wrappers.lambdaQuery(LampCount.class));
|
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);
|
updateById(one);
|
|
return formattedDate+formattedDate1+formattedDate2+number;
|
|
}
|
@Scheduled(cron = "0 0 0 * * ?")
|
public void reset(){
|
LampCount one = getOne(Wrappers.lambdaQuery(LampCount.class));
|
one.setCount(4);
|
updateById(one);
|
}
|
}
|