|
@@ -14,6 +14,7 @@ import com.community.huiju.exception.WisdomException;
|
14
|
14
|
import com.community.huiju.model.*;
|
15
|
15
|
import com.community.huiju.service.IBillInvoiceService;
|
16
|
16
|
import com.community.huiju.service.IBillService;
|
|
17
|
+import com.community.huiju.service.IBuildingOwnerInfoService;
|
17
|
18
|
import com.google.common.collect.Lists;
|
18
|
19
|
import com.google.common.collect.Maps;
|
19
|
20
|
import com.google.zxing.common.detector.MathUtils;
|
|
@@ -31,10 +32,7 @@ import org.springframework.stereotype.Service;
|
31
|
32
|
import org.springframework.transaction.annotation.Transactional;
|
32
|
33
|
import org.springframework.web.multipart.MultipartFile;
|
33
|
34
|
|
34
|
|
-import java.io.FileInputStream;
|
35
|
|
-import java.io.FileNotFoundException;
|
36
|
|
-import java.io.IOException;
|
37
|
|
-import java.io.InputStream;
|
|
35
|
+import java.io.*;
|
38
|
36
|
import java.text.ParseException;
|
39
|
37
|
import java.text.SimpleDateFormat;
|
40
|
38
|
import java.util.Date;
|
|
@@ -81,6 +79,8 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
|
81
|
79
|
@Autowired
|
82
|
80
|
private TaUserMapper taUserMapper;
|
83
|
81
|
|
|
82
|
+ @Autowired
|
|
83
|
+ private IBuildingOwnerInfoService iBuildingOwnerInfoService;
|
84
|
84
|
|
85
|
85
|
@Override
|
86
|
86
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -229,10 +229,10 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
|
229
|
229
|
|
230
|
230
|
bill.setPayedNum(0);
|
231
|
231
|
bill.setBillStatus(billStatus);
|
232
|
|
- bill.setCreateUser(userElement.getId());
|
233
|
232
|
//为草稿时不创建时间
|
234
|
233
|
if(!"2".equals(billStatus)) {
|
235
|
234
|
bill.setCreateDate(new Date());
|
|
235
|
+ bill.setCreateUser(userElement.getId());
|
236
|
236
|
}
|
237
|
237
|
bill.setCommunityId(userElement.getCommunityId());
|
238
|
238
|
Integer payTotalNum = tempBills.size() != 0 ? tempBills.size() : records != null ? records.size() : 0;
|
|
@@ -250,6 +250,10 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
|
250
|
250
|
if (billId != null) {
|
251
|
251
|
bill.setCreateUser(null);
|
252
|
252
|
bill.setCreateDate(null);
|
|
253
|
+ if(!"2".equals(billStatus)) {
|
|
254
|
+ bill.setCreateDate(new Date());
|
|
255
|
+ bill.setCreateUser(userElement.getId());
|
|
256
|
+ }
|
253
|
257
|
// 设置主键, 表示修改
|
254
|
258
|
bill.setId(billId);
|
255
|
259
|
}
|
|
@@ -271,8 +275,15 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
|
271
|
275
|
queryWrapper.eq("room_no", e.getRoomNo());
|
272
|
276
|
queryWrapper.eq("community_id", userElement.getCommunityId());
|
273
|
277
|
TpBuildingOwnerInfo buildingOwnerInfo = tpBuildingOwnerInfoMapper.selectOne(queryWrapper);
|
|
278
|
+ if (null == buildingOwnerInfo) {
|
|
279
|
+ throw new WisdomException("请输入正确的用户信息! ");
|
|
280
|
+ }
|
|
281
|
+
|
|
282
|
+ /**
|
|
283
|
+ * 如果用户不在 app 里面,没有关联, 那么就设置 taUserId
|
|
284
|
+ * 等业主第一次登陆的时候, 再去自动匹配上去
|
|
285
|
+ */
|
274
|
286
|
|
275
|
|
- // TODO 如果用户不在 app 里面,没有关联, 怎么处理?
|
276
|
287
|
// 查询app用户id
|
277
|
288
|
QueryWrapper<TaUser> userQueryWrapper = new QueryWrapper<>();
|
278
|
289
|
userQueryWrapper.eq("community_id", userElement.getCommunityId());
|
|
@@ -280,7 +291,9 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
|
280
|
291
|
TaUser taUser = taUserMapper.selectOne(userQueryWrapper);
|
281
|
292
|
|
282
|
293
|
billInvoice.setBuildingOwnerInfoId(buildingOwnerInfo.getId());
|
283
|
|
- billInvoice.setTaUserId(taUser.getId());
|
|
294
|
+ if (null != taUser) {
|
|
295
|
+ billInvoice.setTaUserId(taUser.getId());
|
|
296
|
+ }
|
284
|
297
|
billInvoice.setBillInvoiceExplain(bill.getBillExplain());
|
285
|
298
|
billInvoice.setPayPrice(e.getMoney());
|
286
|
299
|
billInvoice.setBillStatus("0");
|
|
@@ -468,62 +481,69 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
|
468
|
481
|
}
|
469
|
482
|
|
470
|
483
|
@Override
|
471
|
|
- public ResponseBean downloadExcel(String parameter) {
|
|
484
|
+ public ResponseBean downloadExcel(UserElement userElement) {
|
472
|
485
|
ResponseBean responseBean = new ResponseBean();
|
473
|
486
|
|
474
|
487
|
InputStream inputStream = null;
|
|
488
|
+ inputStream = this.getClass().getResourceAsStream("/缴费单模板.xls");
|
|
489
|
+
|
475
|
490
|
HSSFWorkbook workbook = null;
|
476
|
491
|
try {
|
477
|
|
- inputStream = new FileInputStream("缴费单模板.xls");
|
478
|
492
|
workbook = new HSSFWorkbook(inputStream);
|
479
|
|
- } catch (FileNotFoundException e) {
|
480
|
|
- e.printStackTrace();
|
481
|
493
|
} catch (IOException e) {
|
482
|
494
|
e.printStackTrace();
|
483
|
495
|
}
|
484
|
496
|
|
485
|
|
-
|
486
|
|
- HSSFSheet sheet = workbook.createSheet("缴费单");
|
|
497
|
+ HSSFSheet sheet = workbook.getSheetAt(0);
|
487
|
498
|
// 创建行
|
488
|
|
- HSSFRow row = sheet.createRow(0);
|
|
499
|
+ HSSFRow row = null;
|
489
|
500
|
// 创建列
|
490
|
|
- HSSFCell cell = row.createCell(0);
|
491
|
|
- cell.setCellValue("1.第1行到第4行为模板说明。第5行为列头。第6行为示例。第7行及以后行中的金额部分为需要您填写的区域。请不要删除任何列、说明以及示例等。");
|
492
|
|
- row = sheet.createRow(1);
|
493
|
|
- cell = row.createCell(0);
|
494
|
|
- cell.setCellValue("2.下表中 栋/单元/楼层/房号/业主姓名为系统生成,自行增加、修改无效,只能修改金额!!!如果没有内容或缺失内容,请先登录物业系统,在 社区管理——业主/楼盘——楼盘库中添加楼盘信息,在社区管理——业主/楼盘——业主资料库中添加业主信息,完成后再重新下载账单模板。");
|
495
|
|
- row = sheet.createRow(2);
|
496
|
|
- cell = row.createCell(0);
|
497
|
|
- cell.setCellValue("3.无需缴费的户可以直接在户所在行最左侧行号上点击右键删除行。");
|
498
|
|
- row = sheet.createRow(3);
|
499
|
|
- cell = row.createCell(0);
|
500
|
|
- cell.setCellValue("4.需要缴费的户,在金额列中填写金额,默认单位为人民币元,请输入大于0的数字,小数点请用英文小数点,更不能使用句号。最多保留小数点后两位。若是复制粘贴的金额,请在粘贴后检查金额是否正确,系统暂时无法退费,请仔细核对账单");
|
501
|
|
- row = sheet.createRow(4);
|
502
|
|
- cell = row.createCell(0);
|
503
|
|
- cell.setCellValue("期/区");
|
504
|
|
- cell = row.createCell(1);
|
505
|
|
- cell.setCellValue("栋");
|
506
|
|
- cell = row.createCell(2);
|
507
|
|
- cell.setCellValue("单元");
|
508
|
|
- cell = row.createCell(3);
|
509
|
|
- cell.setCellValue("楼层");
|
510
|
|
- cell = row.createCell(4);
|
511
|
|
- cell.setCellValue("房号");
|
512
|
|
- cell = row.createCell(5);
|
513
|
|
- cell.setCellValue("业主姓名");
|
514
|
|
- cell = row.createCell(6);
|
515
|
|
- cell.setCellValue("金额(元)");
|
516
|
|
-
|
517
|
|
- String [] [] data = new String[][] {{"1区","0", "0", "0", "0", "示例忽删", "12.34", "<-示例"}};
|
518
|
|
- int crrentRow = 5;
|
519
|
|
- // 行数
|
520
|
|
- for (int i = 0; i < data.length; i++) {
|
521
|
|
- row = sheet.createRow(i + crrentRow);
|
522
|
|
- for (int t = 0; t < data[i].length; t++) {
|
523
|
|
- cell = row.createCell(t);
|
524
|
|
- cell.setCellValue(data[i][t]);
|
|
501
|
+ HSSFCell cell = null;
|
|
502
|
+
|
|
503
|
+ Integer pageNum = 1;
|
|
504
|
+ Integer pageSize = 10;
|
|
505
|
+ Page<TpBuildingOwnerInfo> page = new Page(pageNum,pageSize);
|
|
506
|
+ // 分页查询
|
|
507
|
+ QueryWrapper<TpBuildingOwnerInfo> buildingOwnerInfoQueryWrapper = new QueryWrapper<>();
|
|
508
|
+ buildingOwnerInfoQueryWrapper.eq("community_id", userElement.getCommunityId());
|
|
509
|
+ IPage<TpBuildingOwnerInfo> infoIPage = tpBuildingOwnerInfoMapper.selectPage(page, buildingOwnerInfoQueryWrapper);
|
|
510
|
+ List<TpBuildingOwnerInfo> records = infoIPage.getRecords();
|
|
511
|
+ // 总页数
|
|
512
|
+ Long pages = infoIPage.getPages();
|
|
513
|
+ do {
|
|
514
|
+
|
|
515
|
+ } while (false);
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+ // 行数 默认从 第 6 行开始
|
|
519
|
+ int currentRow = 6;
|
|
520
|
+ // 记录坐标
|
|
521
|
+ int index = 0;
|
|
522
|
+
|
|
523
|
+ do {
|
|
524
|
+ TpBuildingOwnerInfo buildingOwnerInfo = records.get(index);
|
|
525
|
+ row = sheet.createRow(currentRow);
|
|
526
|
+ cell = row.createCell(0);
|
|
527
|
+ cell.setCellValue(buildingOwnerInfo.getPhase());
|
|
528
|
+ cell = row.createCell(1);
|
|
529
|
+ cell.setCellValue(buildingOwnerInfo.getBuilding());
|
|
530
|
+ cell = row.createCell(2);
|
|
531
|
+ cell.setCellValue(buildingOwnerInfo.getUnit());
|
|
532
|
+ cell = row.createCell(3);
|
|
533
|
+ cell.setCellValue(buildingOwnerInfo.getLevel());
|
|
534
|
+ cell = row.createCell(4);
|
|
535
|
+ cell.setCellValue(buildingOwnerInfo.getRoomNo());
|
|
536
|
+ cell = row.createCell(5);
|
|
537
|
+ cell.setCellValue(buildingOwnerInfo.getOwnerName());
|
|
538
|
+ currentRow ++;
|
|
539
|
+ index ++;
|
|
540
|
+ if (index == records.size()) {
|
|
541
|
+ index = 0;
|
|
542
|
+ page = new Page(infoIPage.getCurrent() + 1,pageSize);
|
|
543
|
+ infoIPage = tpBuildingOwnerInfoMapper.selectPage(page, buildingOwnerInfoQueryWrapper);
|
|
544
|
+ records = infoIPage.getRecords();
|
525
|
545
|
}
|
526
|
|
- }
|
|
546
|
+ } while (infoIPage.getCurrent() <= pages);
|
527
|
547
|
|
528
|
548
|
responseBean.addSuccess(workbook);
|
529
|
549
|
return responseBean;
|