cf1997c5a35a1dbb380a78c4f7f5a06d6b8946a6.svn-base
7.88 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/**
* Copyright © 2015-2018 ODM All rights reserved.
*/
package com.thinkgem.jeesite.modules.reg.service.base;
import java.io.IOException;
import java.io.InputStream;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.reg.dao.base.RegBaseZbinfoZrzDao;
import com.thinkgem.jeesite.modules.reg.dao.base.RegBaseZrzDao;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseZbinfoZrz;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseZrz;
/**
* 自然幢信息维护Service
* @author xuyg
* @version 2015-10-28
*/
@Service
@Transactional(readOnly = true)
public class RegBaseZrzService extends CrudService<RegBaseZrzDao, RegBaseZrz> {
@Autowired
private RegBaseZbinfoZrzDao regBaseZbinfoDao;
public RegBaseZrz get(String id) {
RegBaseZrz regBaseZrz = super.get(id);
return regBaseZrz;
}
public long getZrzMaxBsm(){
if("oracle".equals(Global.getDbName())){
return dao.getZrzMaxBsmofOracle();
}else{
return dao.getZrzMaxBsm();
}
}
public String getczds(String bdcdyh){
return dao.getczds(bdcdyh);
}
public List<String> findZddms(String xmid){
return dao.findZddms(xmid);
}
public RegBaseZrz getRegBaseZrz(String bdcdyh) {
return dao.getRegBaseZrz(bdcdyh);
}
public List<RegBaseZrz> getListByZddm(RegBaseZrz regBaseZrz) {
return dao.getListByZddm(regBaseZrz);
}
public List<RegBaseZrz> findList(RegBaseZrz regBaseZrz) {
return super.findList(regBaseZrz);
}
public List<RegBaseZrz> findJzwmcList(RegBaseZrz regBaseZrz) {
return dao.findJzwmcList(regBaseZrz);
}
public List<RegBaseZrz> findzrzhsxhList(RegBaseZrz regBaseZrz) {
return dao.findzrzhsxhList(regBaseZrz);
}
//界址点导入修改后生成楼栋不动产单元号
public List<RegBaseZrz> findzrzhList(RegBaseZrz regBaseZrz) {
return dao.findzrzhList(regBaseZrz);
}
public Page<RegBaseZrz> findPage(Page<RegBaseZrz> page, RegBaseZrz regBaseZrz) {
return super.findPage(page, regBaseZrz);
}
@Transactional(readOnly = false)
public void save(RegBaseZrz regBaseZrz) {
super.save(regBaseZrz);
}
/*@Transactional(readOnly = false)
public void zrzzbxxsave(RegBaseZrz regBaseZrz){
for (RegBaseZbinfoZrz regBaseZbinfoZrz : regBaseZrz.getRegBaseZbinfoZrzList()){
if (regBaseZbinfoZrz.getId() == null){
continue;
}
if (RegBaseZbinfoZrz.DEL_FLAG_NORMAL.equals(regBaseZbinfoZrz.getDelFlag())){
if (StringUtils.isBlank(regBaseZbinfoZrz.getId())){
regBaseZbinfoZrz.setMainIdZrz(regBaseZrz);
regBaseZbinfoZrz.preInsert();
regBaseZbinfoZrzDao.insert(regBaseZbinfoZrz);
}else{
regBaseZbinfoZrz.preUpdate();
regBaseZbinfoZrzDao.update(regBaseZbinfoZrz);
}
}else{
regBaseZbinfoZrzDao.delete(regBaseZbinfoZrz);
}
}
}*/
@Transactional(readOnly = false)
public void savebat(RegBaseZrz regBaseZrz) {
super.savebat(regBaseZrz);
}
@Transactional(readOnly = false)
public void delete(RegBaseZrz regBaseZrz) {
super.delete(regBaseZrz);
}
@Transactional(readOnly = false)
public void zrzdelete(RegBaseZrz regBaseZrz) {
dao.zrzdelete(regBaseZrz);
}
public List<RegBaseZrz> importRegBaseZrz(InputStream in) throws IOException {
List<RegBaseZrz> regBaseZrzs = readRegBaseZrzXls(in);
return regBaseZrzs;
}
private List<RegBaseZrz> readRegBaseZrzXls(InputStream is) throws IOException{
HSSFWorkbook hssfWorkbook = new HSSFWorkbook(is);
List<RegBaseZrz> regBaseZrzs = new ArrayList<RegBaseZrz>();
RegBaseZrz regBaseZrz;
// 循环工作表Sheet
HSSFSheet hssfSheet = hssfWorkbook.getSheetAt(1);
// 循环行Row
for (int rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
regBaseZrz = new RegBaseZrz();
HSSFRow hssfRow = hssfSheet.getRow(rowNum);
for (int cellNum = 0; cellNum < hssfRow.getLastCellNum(); cellNum++){
HSSFCell hssfCell = hssfRow.getCell(cellNum);
if(hssfCell==null){
continue;
}
String strCell = getValue(hssfCell);
if (cellNum == 0) {
regBaseZrz.setXmmc(strCell);
} else if (cellNum == 1) {
regBaseZrz.setZddm(strCell);
} else if (cellNum == 2) {
regBaseZrz.setGzwmc(strCell);
} else if (cellNum == 3) {
regBaseZrz.setZzdmj(Double.valueOf(strCell));
} else if (cellNum == 4) {
regBaseZrz.setScjzmj(Double.valueOf(strCell));
} else if (cellNum == 5) {
regBaseZrz.setZcs(Integer.valueOf(strCell));
} else if (cellNum == 6) {
regBaseZrz.setDscs(strCell);
} else if (cellNum == 7) {
regBaseZrz.setGhyt(strCell);
} else if (cellNum == 8) {
regBaseZrz.setFwjg(strCell);
} else if (cellNum == 9) {
regBaseZrz.setZdftfs(strCell);
} else if (cellNum == 10) {
regBaseZrz.setZrzh(strCell);
} else if (cellNum == 11) {
regBaseZrz.setDxcs(strCell);
} else if (cellNum == 12) {
SimpleDateFormat s1 = new SimpleDateFormat("yyyy.MM.dd");
try {
regBaseZrz.setJgrq(s1.parse(strCell));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else if (cellNum == 13) {
regBaseZrz.setJzwgd(Double.valueOf(strCell));
} else if (cellNum == 14) {
regBaseZrz.setZydmj(Double.valueOf(strCell));
} else if (cellNum == 15) {
regBaseZrz.setZts(Integer.valueOf(strCell));
} else if (cellNum == 16) {
regBaseZrz.setJzwjbyt(strCell);
} else if (cellNum == 17) {
regBaseZrz.setDah(strCell);
} else if (cellNum == 18) {
regBaseZrz.setBz(strCell);
} else if (cellNum == 19) {
regBaseZrz.setZt(strCell);
} else if (cellNum == 20) {
String nextZHSort = "0000";
nextZHSort = String.valueOf(Integer.valueOf(nextZHSort)+1);
regBaseZrz.setBdcdyh(regBaseZrz.getZddm()+"F"+ nextZHSort +"0000");
break;
}
}
regBaseZrzs.add(regBaseZrz);
}
return regBaseZrzs;
}
@SuppressWarnings("static-access")
private String getValue(HSSFCell hssfCell){
if(hssfCell.getCellType() == hssfCell.CELL_TYPE_BOOLEAN){
return String.valueOf( hssfCell.getBooleanCellValue());
}else if(hssfCell.getCellType() == hssfCell.CELL_TYPE_NUMERIC){
DecimalFormat df = new DecimalFormat("###0.###");
return df.format(hssfCell.getNumericCellValue()).toString();
// return String.valueOf( hssfCell.getNumericCellValue());
}else if (hssfCell.getCellType() ==hssfCell.CELL_TYPE_STRING){
return String.valueOf(hssfCell.getStringCellValue());
}else{
return String.valueOf( hssfCell.getStringCellValue());
}
}
public List<RegBaseZrz> findListZb(RegBaseZrz zrz) {
return dao.findListZb(zrz);
}
public RegBaseZrz getByZddmZrzh(String zddm, String zrzh) {
// TODO Auto-generated method stub
return dao.getByZddmZrzh(zddm, zrzh);
}
public RegBaseZrz getByZrzh(String zrzh) {
// TODO Auto-generated method stub
return dao.getByZrzh(zrzh);
}
}