Repository navigation
Expand file tree
/
Copy pathSecondService.java
More file actions
executable file
·104 lines (97 loc) · 2.79 KB
/
Copy pathSecondService.java
File metadata and controls
executable file
·104 lines (97 loc) · 2.79 KB
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
package second;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import kqb.Job;
import kqb.Size;
import org.apache.struts2.ServletActionContext;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import basis.Hfsession;
import basis.ResultUtils;
import second.Second;
import admin.Admin;
public class SecondService {
public static Integer getSecondId(){
Session session = Hfsession.init();
Transaction tx = session.beginTransaction();
Map<String,Object> map = new HashMap<String,Object>();
List<Second> list = new ArrayList<Second>();
Second second = new Second();
try {
Query q = session.createQuery("from Second order by secondId desc");
list = q.list();
tx.commit();
Hfsession.close();
} catch (Exception e) {
e.printStackTrace();
}
if(list.size()>0){
return list.get(0).getSecondId()+1;
}
return 1;
}
public static List<Second> getListSecond(){
Session session = Hfsession.init();
Transaction tx = session.beginTransaction();
List<Second> list = new ArrayList<Second>();
try {
Query q = session.createQuery("from Second order by createDate desc");
list = q.list();
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
public static Map<String,String> getListSize(){
Session session = Hfsession.init();
List<Size> list = new ArrayList<Size>();
Map<String,String> map = new HashMap<>();
try {
Query q = session.createQuery("from Size where 1=1");
list = q.list();
for(int i =0;i<list.size();i++){
map.put(list.get(i).getSizeid()+"", list.get(i).getName());
}
} catch (Exception e) {
e.printStackTrace();
}
return map;
}
@SuppressWarnings("null")
public static Map<String,String> getListJob(){
Session session = Hfsession.init();
List<Job> list = new ArrayList<Job>();
Map<String,String> map = new HashMap<>();
try {
Query q = session.createQuery("from Job where 1=1 ");
list = q.list();
for(int i =0;i<list.size();i++){
map.put(list.get(i).getSecondId()+"", list.get(i).getName());
}
} catch (Exception e) {
e.printStackTrace();
}
return map;
}
@SuppressWarnings("null")
public static Map<String,String> getSecondMap(){
Session session = Hfsession.init();
List<Second> list = new ArrayList<Second>();
Map<String,String> map = new HashMap<>();
try {
Query q = session.createQuery("from Second where 1=1 ");
list = q.list();
for(int i =0;i<list.size();i++){
map.put(list.get(i).getSecondId()+"", list.get(i).getName());
}
} catch (Exception e) {
e.printStackTrace();
}
return map;
}
}