1
81041
2019-06-20 ab3c4acf83f54f8449ca8664c4a2bb79bd30f297
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package com.fgkj.actions;
 
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Blob;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import com.fgkj.dto.BattInf;
import com.fgkj.dto.Deverror_record;
import com.fgkj.dto.ServiceModel;
import com.fgkj.dto.User_inf;
import com.fgkj.services.Deverror_recordService;
 
public class Deverror_recordAction extends ActionUtil{
    private Deverror_recordService service=new Deverror_recordService();
    private String json;
    private String result;
    private List<File> file;
    //用户手动添加问题
    public String add(){
        Deverror_record dev_record=getGson("yyyy-MM-dd HH:mm:ss").fromJson(json, Deverror_record.class);
        User_inf uinf=(User_inf) getUser();
        dev_record.setUid(uinf.getUId());
        dev_record.setUname(uinf.getUName());
        if(file!=null&&file.size()>0){
            for (int i=0;i<file.size();i++) {
                switch (i) {
                case 0:
                    dev_record.setPicture_one(file.get(i));
                    break;
                case 1:
                    dev_record.setPicture_two(file.get(i));
                    break;
                case 2:
                    dev_record.setPicture_three(file.get(i));
                    break;
                case 3:
                    dev_record.setPicture_four(file.get(i));
                    break;
                default:
                    break;
                }
            }
        }
        //dev_record.setPicture_num(file.size());
        //System.out.println(dev_record);
        ServiceModel model=service.add(dev_record);
        result=tojson(model);
        return SUCCESS;
    }
     //用户处理的结果
    public String update(){
        Deverror_record dev_record=getGson("yyyy-MM-dd HH:mm:ss").fromJson(json, Deverror_record.class);
        User_inf uinf=(User_inf) getUser();
        dev_record.setSolve_uid(uinf.getUId());
        dev_record.setSolve_uname(uinf.getUName());
        if(file!=null&&file.size()>0){
            for (int i=0;i<file.size();i++) {
                switch (i) {
                case 0:
                    dev_record.setSolve_picture_one(file.get(i));
                    break;
                case 1:
                    dev_record.setSolve_picture_two(file.get(i));
                    break;
                case 2:
                    dev_record.setSolve_picture_three(file.get(i));
                    break;
                case 3:
                    dev_record.setSolve_picture_four(file.get(i));
                    break;
                default:
                    break;
                }
            }
        }
        ServiceModel model=service.update(dev_record);
        result=tojson(model);
        return SUCCESS;
    }
    //根据stationid查询设备的问题记录
    public String serchByCondition(){
        BattInf binf=getGson().fromJson(json, BattInf.class);
        User_inf uinf=(User_inf) getUser();
        binf.setNum(uinf.getUId());
        ServiceModel model=service.serchByCondition(binf);
        result=tojson(model);
        return SUCCESS;
    }
    //根据num和列名查询图片(note放列名字)
    public void serchByInfo(){
        InputStream is = null;
        OutputStream os =null;
        Deverror_record dev_record=getGson("yyyy-MM-dd").fromJson(json, Deverror_record.class);
        ServiceModel model=service.serchByInfo(dev_record);
        if(model.code == 1){
            List list = (List) model.getData();
            Blob blob = (Blob) list.get(0);
            try {
                is = blob.getBinaryStream();
                os = ActionUtil.getResponse().getOutputStream();
                byte[] image = IStoByteArr(is);
                os.write(image);
                os.flush();
            } catch (SQLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } finally{
                if(os != null){
                    try {
                        os.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
    
    public String getResult() {
        return result;
    }
    public void setJson(String json) {
        this.json = json;
    }
    public List<File> getFile() {
        return file;
    }
    public void setFile(List<File> file) {
        this.file = file;
    }
    
 
}