MemberService.java
2.95 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
/**
* Copyright © 2015-2018 ODM All rights reserved.
*/
package com.pudp.bae.service;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.sql.Clob;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.pudp.bae.dao.redis.MemberDao;
import com.pudp.bae.model.Member;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.mapper.JsonMapper;
import com.thinkgem.jeesite.modules.reg.dao.base.BdcDao;
import com.thinkgem.jeesite.modules.reg.entity.base.DmlRecords;
@Service
@Transactional(readOnly = true)
public class MemberService {
@Resource(name="memberDao")
private MemberDao memberDao;
@Autowired
private BdcDao bdcDao;
public void setMemberDao(MemberDao memberDao)
{
this.memberDao = memberDao;
}
@Transactional(readOnly = false)
public void add(Member member){
memberDao.add(member);
}
@Transactional(readOnly = false)
public void delete(String id){
memberDao.delete(id);
}
public Member get(String id)
{
return memberDao.get(id);
}
/**
* 根据dml操作记录保存redis
* @return
* @throws SQLException
* @throws IOException
*/
@Transactional(readOnly = false)
public String selectDmlRecords(DmlRecords dmlRecords) throws SQLException, IOException {
String success = "";
Member member = new Member();
Map<String, Object> bdcmap = null;
if(!"DELETE".equals(dmlRecords.getDmllx())) {
bdcmap = bdcDao.selDate(dmlRecords.getTablename(),dmlRecords.getTableid());
//keySet获取map集合key的集合 然后在遍历key即可
for(String key : bdcmap.keySet()){
//判断map值是否为Clob
if(bdcmap.get(key) instanceof Clob) {
Clob clob = (Clob) bdcmap.get(key);
Reader is = clob.getCharacterStream();// 得到流
BufferedReader br = new BufferedReader(is);
String s = br.readLine();
StringBuffer sb = new StringBuffer();
// 执行循环将字符串全部取出付值给StringBuffer由StringBuffer转成STRING
while (s != null) {
sb.append(s);
s = br.readLine();
}
is.close();
br.close();
bdcmap.put(key, sb.toString());
}
}
}
member.setId(dmlRecords.getId());
Map<String, Object> map_new_sett = new HashMap<String, Object>();
map_new_sett.put("dmlRecords", dmlRecords);
map_new_sett.put("qxdm", Global.getAreaCode());
map_new_sett.put("data", bdcmap);
member.setNickname(JsonMapper.toJsonString(map_new_sett));
try {
add(member);
success = "success";
} catch (Exception e) {
e.printStackTrace();
success = e.getMessage();
}
return success;
}
}