2021与蓝度共同重构项目,服务端
fix
zhanzhiqin
2022-02-28 d877cf557db5452093087fabb4479a10497ee218
ximon-admin/src/main/java/com/sandu/ximon/admin/security/CountSet.java
对比新文件
@@ -0,0 +1,61 @@
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 org.springframework.stereotype.Service;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@Component
@Slf4j
@AllArgsConstructor
@EnableScheduling
@Service
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 reSetCount(){
        //LampCount one = getOne(Wrappers.lambdaQuery(LampCount.class));
        LampCount one=  lampCountService.list().get(0);
        one.setCount(4);
        lampCountService.updateById(one);
    }
}