1
2
3
4
5 package gboat2.approve.business.impl;
6
7 import gboat2.approve.business.IApproveRecordBusiness;
8 import gboat2.approve.model.ApproveRecord;
9 import gboat2.approve.model.ApproveRecordItem;
10 import gboat2.approve.model.ApproveStatus;
11 import gboat2.base.core.dao.QuerySupport;
12 import gboat2.base.core.service.BaseService;
13
14 import java.util.HashMap;
15 import java.util.List;
16 import java.util.Map;
17
18 import org.apache.commons.lang3.StringUtils;
19 import org.springframework.stereotype.Service;
20
21
22
23
24
25
26
27
28 @Service
29 public class ApproveRecordBusinessImpl extends BaseService implements IApproveRecordBusiness {
30 @Override
31 public ApproveRecord getApproveRecord(String recordObjectId,String recordType) {
32 String[][] params = {
33 { ApproveRecord.class.getName() },
34 { "_recordObjectId", recordObjectId } ,
35 { "_recordObjectType", recordType}
36 };
37
38 return (ApproveRecord) baseDAO.get(params);
39 }
40
41 @Override
42 public ApproveRecord getApproveRecord(String recordId) {
43 String[][] params = { { ApproveRecord.class.getName() }, { "_recordId", recordId } };
44
45 return (ApproveRecord) baseDAO.get(params);
46 }
47
48 @Override
49 public ApproveRecordItem getApproveRecordItem(String recordItemId) {
50 String[][] params = {
51 { ApproveRecordItem.class.getName() },
52 { "_itemId", recordItemId } };
53 return (ApproveRecordItem) baseDAO.get(params);
54 }
55
56 @Override
57 public ApproveRecordItem getApproveRecordItem(String recordId, String assigner) {
58 Map<String, Object> params = new HashMap<String, Object>();
59 params.put(QuerySupport.PARAM_TABLENAME, ApproveRecordItem.class);
60 params.put("_recordId", recordId);
61 params.put("_assigner", assigner);
62 Object obj = baseDAO.get(params);
63 if (obj != null) {
64 return (ApproveRecordItem) obj;
65 }
66 return null;
67 }
68
69 @Override
70 public List<ApproveRecordItem> getApproveRecordItemListByRecordId(String recordId) {
71 Map<String, Object> params = new HashMap<String, Object>();
72 params.put(QuerySupport.PARAM_TABLENAME, ApproveRecordItem.class);
73 params.put("_recordId", recordId);
74 List list = baseDAO.queryList(params);
75 if (list == null) {
76 return null;
77 }
78 List<ApproveRecordItem> returnList = (List<ApproveRecordItem>) list;
79
80 return returnList;
81 }
82
83 @Override
84 public ApproveRecord getApproveRecordByRecordObject(String recordObjectId) {
85 String[][] params = {
86 { ApproveRecord.class.getName() },
87 { "_recordObjectId", recordObjectId } };
88 List<ApproveRecord> records = (List<ApproveRecord>) query(params);
89 if (records != null && records.size() > 0) {
90 return records.get(0);
91 }
92
93 return null;
94 }
95
96 @Override
97 public ApproveStatus getApproveStatusOfRecord(String recordId) {
98 String[][] params = {
99 {ApproveRecordItem.class.getName()},
100 {"_recordId",recordId},
101 {"_approveTime_notnull","notnull"},
102 {QuerySupport.PARAM_ORDERBY,"createTime desc,approveTime desc"}
103 };
104 List<ApproveRecordItem> items = (List<ApproveRecordItem>)query(params);
105 if(items.size()>0){
106 ApproveRecordItem item = items.get(0);
107 return item.getApproveStatus();
108 }
109 return null;
110 }
111
112 @Override
113 public ApproveRecordItem getApproveRecordItem(String recordId,String[] assigners) {
114 if(!StringUtils.isEmpty(recordId)&&assigners!=null&&assigners.length>0){
115 Map<String, Object> params = new HashMap<String, Object>();
116 params.put(QuerySupport.PARAM_TABLENAME, ApproveRecordItem.class);
117 String assignerParam = "";
118 for(String assigner : assigners){
119 if(assignerParam.length()>0){
120 assignerParam += "||";
121 }
122 assignerParam += "'"+assigner+"'";
123 }
124 params.put("_assigner_or", assignerParam);
125 params.put("_recordId", recordId);
126 Object obj = baseDAO.get(params);
127 if (obj != null) {
128 return (ApproveRecordItem) obj;
129 }
130 }
131 return null;
132 }
133
134 }