whycrzg
2021-05-18 d723d0ea2888cc5bea09bc8ef268a7bf0159936a
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.whyc.dto.Response;
import com.whyc.mapper.ExperimentMapper;
import com.whyc.mapper.ExperimentWindingStep1Mapper;
import com.whyc.mapper.ExperimentWindingStep2Mapper;
import com.whyc.mapper.ProjectMapper;
import com.whyc.pojo.Experiment;
import com.whyc.pojo.ExperimentWindingStep1;
import com.whyc.pojo.ExperimentWindingStep2;
import com.whyc.pojo.Project;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
@Service
public class WindingExperimentService {
 
 
    @Resource
    private ExperimentMapper mapper;
 
    @Resource
    private ExperimentWindingStep1Mapper mapper1;
 
    @Resource
    private ExperimentWindingStep2Mapper mapper2;
 
    @Resource
    private ProjectMapper projectMapper;
 
    /**
     * 绕组实验 开始实验
     * @param experiment
     * @return
     */
    public Response<Object> addWindingExperiment(Experiment experiment) {
        String id = "RZ_";
        id+=new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
        experiment.setId(id);
        experiment.setCreateTime(new Date());
        experiment.setStatus(0);
        try {
            if (mapper.insertmanual(experiment) > 0) {
                return new Response().setMsg(1, "添加成功");
            } else {
                return new Response().setMsg(0, "添加失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().setMsg(0, "添加失败");
        }
    }
 
    /**
     * 绕组实验步骤1
     * @param windingStep1
     * @return
     */
    public Response<Object> addExperimentWindingStep1(ExperimentWindingStep1 windingStep1) {
        try {
            if (mapper1.insert(windingStep1) > 0) {
                return new Response().setMsg(1, "添加成功");
            } else {
                return new Response().setMsg(0, "添加失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().setMsg(0, "添加失败");
        }
 
    }
 
    /**
     * 绕组实验步骤2
     * @param windingStep2
     * @return
     */
    public Response<Object> addExperimentWindingStep2(ExperimentWindingStep2 windingStep2) {
        try {
            if (mapper2.insert(windingStep2) > 0) {
                return new Response().setMsg(1, "添加成功");
            } else {
                return new Response().setMsg(0, "添加失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().setMsg(0, "添加失败");
        }
 
    }
 
    public Response<List<Project>> getProjectName() {
        QueryWrapper<Project> wrapper = new QueryWrapper<>();
        ArrayList<Object> arr = new ArrayList<>();
        arr.add(1); //项目状态:0-已取消,1-进行中,2-完成,3-延期
        arr.add(3);
        wrapper.in("status", arr);
        List<Project> list = projectMapper.selectList(wrapper);
        Response<List<Project>> response = new Response<>();
        response.set(1, list);
        return response;
    }
 
 
}