1
2
3
4
5 package gboat2.approve.business.impl;
6
7 import gboat2.approve.business.IApproveRecordBusiness;
8 import gboat2.approve.business.IApproveRecordHistoryBusiness;
9 import gboat2.approve.model.ApproveRecord;
10 import gboat2.approve.model.ApproveRecordHistory;
11 import gboat2.approve.model.ApproveRecordItem;
12 import gboat2.base.core.dao.QuerySupport;
13 import gboat2.base.core.service.BaseService;
14
15 import java.util.HashMap;
16 import java.util.List;
17 import java.util.Map;
18
19 import org.springframework.beans.factory.annotation.Autowired;
20 import org.springframework.stereotype.Service;
21
22
23
24
25
26
27
28
29 @Service
30 public class ApproveRecordHistoryBusinessImpl extends BaseService implements IApproveRecordHistoryBusiness {
31
32 @Autowired
33 IApproveRecordBusiness approveRecordBusiness;
34
35 @Override
36 public void recordHistory(String recordItemId) {
37 ApproveRecordItem approveRecordItem = approveRecordBusiness.getApproveRecordItem(recordItemId);
38 recordHistory(approveRecordItem.getRecordId(), approveRecordItem.getAssigner());
39 }
40
41 @Override
42 public void recordHistory(String recordId, String assigner) {
43 ApproveRecord approveRecord = approveRecordBusiness.getApproveRecord(recordId);
44 if (approveRecord == null) {
45 approveRecord = new ApproveRecord();
46 }
47 ApproveRecordItem approveRecordItem = approveRecordBusiness.getApproveRecordItem(recordId, assigner);
48
49 if (approveRecordItem == null) {
50 approveRecordItem = new ApproveRecordItem();
51 }
52 ApproveRecordHistory appRecordHistory = new ApproveRecordHistory();
53
54 appRecordHistory.setRecordObjectHost(approveRecord.getRecordObjectHost());
55 appRecordHistory.setRecordObjectId(approveRecord.getRecordObjectId());
56 appRecordHistory.setRecordObjectType(approveRecord.getRecordObjectType());
57 appRecordHistory.setRecordStatus(approveRecord.getRecordStatus());
58 appRecordHistory.setApproveMemo(approveRecordItem.getApproveMemo());
59 appRecordHistory.setApproveResult(approveRecordItem.getApproveResult());
60 appRecordHistory.setApproveSeal(approveRecordItem.getApproveSeal());
61 appRecordHistory.setApproveStatus(approveRecordItem.getApproveStatus());
62 appRecordHistory.setApproveTime(approveRecord.getApproveTime());
63 appRecordHistory.setAssigner(approveRecordItem.getAssigner());
64 appRecordHistory.setRecordObjectHost(approveRecord.getRecordObjectHost());
65 appRecordHistory.setSubmitTime(approveRecord.getSubmitTime());
66
67 save(appRecordHistory);
68 }
69
70 public ApproveRecordHistory getApproveRecordHistory(String recordItemHistoryId) {
71 String[][] params = { { ApproveRecord.class.getName() }, { "_recordItemHistoryId", recordItemHistoryId } };
72
73 return (ApproveRecordHistory) baseDAO.get(params);
74 }
75
76 @Override
77 public List<ApproveRecordHistory> getAllApproveRecordHistory(String recordObjectId) {
78 Map<String, Object> params = new HashMap<String, Object>();
79 params.put(QuerySupport.PARAM_TABLENAME, ApproveRecordHistory.class);
80 params.put("_recordObjectId", recordObjectId);
81 List<ApproveRecordHistory> list = (List<ApproveRecordHistory>) super.query(params);
82 return list;
83 }
84
85 public boolean isApproveHistoryExist(String recordObjectId){
86 String hql = "select count(*) from ApproveRecordHistory where recordObjectId=:_recordObjectId and stepName=:_stepName";
87 Map<String, Object> params = new HashMap<String, Object>();
88 params.put("_recordObjectId", recordObjectId);
89 params.put("_stepName", "审核");
90
91 Object rs = baseDAO.get(hql, params);
92 if(rs!=null){
93 return ((Long)rs).intValue()>0;
94 }
95 return false;
96 }
97 }