2021与蓝度共同重构项目,服务端
liuhaonan
2021-11-26 2648c79d0ef069ae5a22974a77a2f1100f6bb2a0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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);
    }
}