whyclxw
2025-05-15 96510a549bfb313920bf297b28089c4cf57f0146
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
64
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.whyc.dto.ProcessServerDao;
import com.whyc.dto.Response;
import com.whyc.mapper.ProcessSurveyMapper;
import com.whyc.pojo.plus_user.ProcessSurvey;
import com.whyc.util.ActionUtil;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
 
@Service
public class ProcessSurveyService {
    @Resource
    private ProcessSurveyMapper mapper;
 
    public Response getAll(){
        QueryWrapper<ProcessSurvey> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByAsc("num");
        List<ProcessSurvey> list = mapper.selectList(queryWrapper);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return new Response().setII(1,list,sdf.format(new Date()),"查询成功");
    }
 
    public Response updateById(ProcessSurvey survey){
        mapper.updateById(survey);
        return new Response().set(1,true,"更新成功");
    }
 
    public Response updateServerFlagOff(ProcessSurvey survey){
        UpdateWrapper<ProcessSurvey> updateWrapper = new UpdateWrapper<>();
        updateWrapper.set("serverflag", ProcessServerDao.PROCESS_OFF);
        updateWrapper.eq("processName",survey.getProcessName());
        updateWrapper.eq("serverflag",ProcessServerDao.PROCESS_TEMP);
        mapper.update(survey,updateWrapper);
        return new Response().set(1,true,"更新成功");
    }
 
    public Response updateServerFlagByName(ProcessSurvey survey){
        UpdateWrapper<ProcessSurvey> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("serverName",survey.getServerName());
        mapper.update(survey,updateWrapper);
        return new Response().set(1,true,"更新成功");
    }
 
 
    public void setUpThreadRestart() {
        //主线 --->11001
        threadRestart(11001);
    }
 
    private void threadRestart(int processId) {
        UpdateWrapper<ProcessSurvey> update = Wrappers.update();
        update.set("ServerFlag",0).eq("ProcessId",processId).ne("ServerFlag",2);
        mapper.update((ProcessSurvey) ActionUtil.objeNull,update);
    }
 
}