TaskDao.java
5.21 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package vion.dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import vion.model.FaultLog;
import vion.model.Task;
import java.util.Date;
import java.util.List;
@Repository
public class TaskDao {
@Autowired
private JdbcTemplate jdbcTemplate;
private static final String SELECT_WORKORDRE_ALL = "SELECT * FROM tbl_task_info";
public List<Task> getTaskAll() {
return jdbcTemplate.query(SELECT_WORKORDRE_ALL, new BeanPropertyRowMapper<Task>(Task.class));
}
private static final String SELECT_WORKORDRE_BY_ID = "SELECT * FROM tbl_task_info where id=?";
public Task getTaskByID(Integer id) {
List<Task> tasks= jdbcTemplate.query(SELECT_WORKORDRE_BY_ID,new Object[]{id},
new BeanPropertyRowMapper<Task>(Task.class));
if(tasks.size()>0){
return tasks.get(0);
}else{
return null;
}
}
private static final String SELECT_WORKORDRE_BY_PARM= "SELECT * FROM tbl_task_info WHERE account_id=?";
public List<Task> getTaskByParm(Integer accountid,Integer store_id, Date startdate,
Date enddate,Integer status,Integer fault_type) {
StringBuffer getTaskSb = new StringBuffer(SELECT_WORKORDRE_BY_PARM);
if(store_id!=null){
getTaskSb.append(" and store_id = "+store_id+"");
}
if(startdate!=null){
getTaskSb.append(" and repair_date>='"+startdate+"'");
}
if(enddate!=null){
getTaskSb.append(" and repair_date<='"+enddate+"'");
}
if(status!=null){
getTaskSb.append(" and status="+status+"");
}
if(fault_type!=null){
getTaskSb.append(" and fault_type="+fault_type+"");
}
return jdbcTemplate.query(getTaskSb.toString(),new Object[]{accountid},
new BeanPropertyRowMapper<Task>(Task.class));
}
private static final String SAVE_WORKORDRE= "INSERT INTO tbl_task_info(\n" +
" store_id, repair_date, fault_type, fault_description, repair_people, \n" +
" repair_phone, status, solve_date, fault_reason, solve_type, solve_description, \n" +
" create_user, remark,account_id)\n" +
" VALUES (?, ?, ?, ?, ?, ?, \n" +
" ?, ?, ?, ?, ?, ?, \n" +
" ?, ? );";
/*
public Task addTask(Task task) {
return jdbcTemplate.queryForObject(SAVE_WORKORDRE,
new Object[]{
task.getStore_id(),task.getRepair_date(),task.getFault_type(),
task.getFault_description(),task.getRepair_people(),task.getRepair_phone(),
task.getStatus(),task.getSolve_date(),task.getFault_reason(),task.getSolve_type(),
task.getSolve_description(),task.getCreate_user(),
task.getRemark(),task.getAccount_id()}
, new BeanPropertyRowMapper<Task>(Task.class));
}
private static final String UPDATE_WORKORDRE= "UPDATE tbl_task_info\n" +
" SET store_id=?, repair_date=?, fault_type=?, fault_description=?, \n" +
" repair_people=?, repair_phone=?, status=?, solve_date=?, fault_reason=?, \n" +
" solve_type=?, solve_description=?, create_user=?, \"current_user\"=?, \n" +
" modify_time=?, remark=?, account_id=?\n" +
" WHERE id=?;";
public Integer updateTask(Task task) {
return jdbcTemplate.update(UPDATE_WORKORDRE,
new Object[]{
task.getStore_id(),task.getRepair_date(),task.getFault_type(),
task.getFault_description(),task.getRepair_people(),task.getRepair_phone(),
task.getStatus(),task.getSolve_date(),task.getFault_reason(),task.getSolve_type(),
task.getSolve_description(),task.getCreate_user(),task.getCurrent_user(),
task.getModify_time(),task.getRemark(),task.getAccount_id(),task.getId()});
}
private static final String SELECT_FAULTLOG_BY_STOREID = "SELECT * FROM tbl_fault_log where store_id=? and workorder_id=?";
public FaultLog getFaultlogByStoreID(Integer store_id,Integer workorder_id) {
List<FaultLog> faultLogs= jdbcTemplate.query(SELECT_FAULTLOG_BY_STOREID,new Object[]{store_id,workorder_id},
new BeanPropertyRowMapper<FaultLog>(FaultLog.class));
if(faultLogs.size()>0){
return faultLogs.get(0);
}else{
return null;
}
}
private static final String SAVE_FAULTLOG= "INSERT INTO tbl_fault_log(\n" +
" store_id, workorder_id, operator, content, remark)\n" +
" VALUES (?, ?, ?, ?, ?);";
public Integer addFaultLog(FaultLog faultLog) {
return jdbcTemplate.update(SAVE_FAULTLOG,
new Object[]{
faultLog.getStore_id(),faultLog.getTask_id(),faultLog.getOperator(),
faultLog.getContent(),faultLog.getRemark()});
}*/
}