Browse Source

修复 bug 4442

魏熙美 6 years ago
parent
commit
62634834b1

+ 3
- 2
CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/BillController.java View File

80
 
80
 
81
     @ApiOperation(value = "上传缴费项接口, 预览", notes = "上传缴费项接口, 预览")
81
     @ApiOperation(value = "上传缴费项接口, 预览", notes = "上传缴费项接口, 预览")
82
     @PostMapping(value = "/bill/uploadExcel/get", consumes = "multipart/*", headers = "content-type=multipart/form-data")
82
     @PostMapping(value = "/bill/uploadExcel/get", consumes = "multipart/*", headers = "content-type=multipart/form-data")
83
-    public ResponseBean getUploadExcel(@RequestParam("file") MultipartFile file) {
83
+    public ResponseBean getUploadExcel(@RequestParam("file") MultipartFile file, HttpSession session) {
84
         ResponseBean responseBean = new ResponseBean();
84
         ResponseBean responseBean = new ResponseBean();
85
-        responseBean = iBillService.getExcelData(file);
85
+        UserElement userElement = getUserElement(session);
86
+        responseBean = iBillService.getExcelData(file, userElement);
86
         return responseBean;
87
         return responseBean;
87
     }
88
     }
88
 
89
 

+ 1
- 1
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/IBillService.java View File

49
 	 * @param file
49
 	 * @param file
50
 	 * @return
50
 	 * @return
51
 	 */
51
 	 */
52
-    ResponseBean getExcelData(MultipartFile file);
52
+    ResponseBean getExcelData(MultipartFile file,  UserElement userElement);
53
 
53
 
54
 	/**
54
 	/**
55
 	 * 上传excel, 解析 入库
55
 	 * 上传excel, 解析 入库

+ 40
- 25
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/BillServiceImpl.java View File

158
 
158
 
159
     @Override
159
     @Override
160
     @Transactional(rollbackFor = Exception.class)
160
     @Transactional(rollbackFor = Exception.class)
161
-    public ResponseBean getExcelData(MultipartFile file) {
161
+    public ResponseBean getExcelData(MultipartFile file, UserElement userElement) {
162
         ResponseBean responseBean = new ResponseBean();
162
         ResponseBean responseBean = new ResponseBean();
163
         if (file == null) {
163
         if (file == null) {
164
             responseBean.addError("对象不能为空");
164
             responseBean.addError("对象不能为空");
165
             return responseBean;
165
             return responseBean;
166
         }
166
         }
167
 
167
 
168
-        responseBean = getExcelData(file, responseBean);
168
+        responseBean = getExcelData(file, responseBean, userElement.getCommunityId());
169
         List<TempBill> tempBills = (List<TempBill>) responseBean.getData();
169
         List<TempBill> tempBills = (List<TempBill>) responseBean.getData();
170
 
170
 
171
         Map<String, Object> map = Maps.newHashMap();
171
         Map<String, Object> map = Maps.newHashMap();
213
             return responseBean;
213
             return responseBean;
214
         }
214
         }
215
 
215
 
216
-        responseBean = getExcelData(file, responseBean);
216
+        responseBean = getExcelData(file, responseBean, userElement.getCommunityId());
217
         List<TempBill> tempBills = (List<TempBill>) responseBean.getData();
217
         List<TempBill> tempBills = (List<TempBill>) responseBean.getData();
218
 
218
 
219
         Double sumDouble = 0.0;
219
         Double sumDouble = 0.0;
273
         // int rows = billMapper.insert(bill);
273
         // int rows = billMapper.insert(bill);
274
         boolean b = this.saveOrUpdate(bill);
274
         boolean b = this.saveOrUpdate(bill);
275
         if (b) {
275
         if (b) {
276
+            QueryWrapper<Message> queryWrapper = new QueryWrapper<>();
277
+            queryWrapper.eq("community_id", userElement.getCommunityId());
278
+            queryWrapper.eq("message_type", "7");
279
+            queryWrapper.eq("model_type", "2");
280
+            queryWrapper.eq("source", "2");
281
+            queryWrapper.eq("status", "1");
282
+            queryWrapper.eq("advice_type","4");
283
+            queryWrapper.eq("bill_id", billId);
284
+            Message message = messageMapper.selectOne(queryWrapper);
276
             // 草稿时插入消息
285
             // 草稿时插入消息
277
-            if ("2".equals(bill.getBillStatus())) {
278
-                Message message = new Message();
286
+            if ("2".equals(bill.getBillStatus()) && null == message) {
287
+                message = new Message();
279
                 message.setCommunityId(userElement.getCommunityId());
288
                 message.setCommunityId(userElement.getCommunityId());
280
                 message.setMessageType("7");
289
                 message.setMessageType("7");
281
                 message.setAdviceType("4");
290
                 message.setAdviceType("4");
295
             }
304
             }
296
             // 发布时消息为无效
305
             // 发布时消息为无效
297
             if ("0".equals(bill.getBillStatus())) {
306
             if ("0".equals(bill.getBillStatus())) {
298
-                QueryWrapper<Message> queryWrapper = new QueryWrapper<>();
299
-                queryWrapper.eq("community_id", userElement.getCommunityId());
300
-                queryWrapper.eq("message_type", "7");
301
-                queryWrapper.eq("model_type", "2");
302
-                queryWrapper.eq("source", "2");
303
-                queryWrapper.eq("status", "1");
304
-                queryWrapper.eq("advice_type","4");
305
-                Message message = messageMapper.selectOne(queryWrapper);
306
                 if (null != message) {
307
                 if (null != message) {
307
                     message.setStatus("0");
308
                     message.setStatus("0");
308
                     message.setUpdateDate(LocalDateTime.now());
309
                     message.setUpdateDate(LocalDateTime.now());
310
                     messageMapper.updateById(message);
311
                     messageMapper.updateById(message);
311
                 }
312
                 }
312
 
313
 
313
-
314
                 // 插入消息表, 消息类型为 消息
314
                 // 插入消息表, 消息类型为 消息
315
                 Message messageModel = new Message();
315
                 Message messageModel = new Message();
316
                 messageModel.setCommunityId(userElement.getCommunityId());
316
                 messageModel.setCommunityId(userElement.getCommunityId());
390
         return responseBean;
390
         return responseBean;
391
     }
391
     }
392
 
392
 
393
-    private ResponseBean getExcelData(MultipartFile file, ResponseBean responseBean) {
393
+    private ResponseBean getExcelData(MultipartFile file, ResponseBean responseBean, Integer communityId) {
394
 
394
 
395
         // 数据
395
         // 数据
396
         List<TempBill> tempBills = Lists.newArrayList();
396
         List<TempBill> tempBills = Lists.newArrayList();
424
             int currentRow = i + 1;
424
             int currentRow = i + 1;
425
             Row row = sheetAt.getRow(i);
425
             Row row = sheetAt.getRow(i);
426
             Cell cell = getCell(row.getCell(0));
426
             Cell cell = getCell(row.getCell(0));
427
+            if (null == cell) {
428
+                throw new WisdomException("第" + currentRow + "行 编号 不能为空");
429
+            }
430
+            // 获取编号
431
+            String roomId = cell.getStringCellValue().trim();
432
+            QueryWrapper<TpRoomNo> roomNoQueryWrapper = new QueryWrapper<>();
433
+            roomNoQueryWrapper.eq("community_id", communityId);
434
+            roomNoQueryWrapper.eq("id", roomId);
435
+            TpRoomNo tpRoomNo = tpRoomNoMapper.selectOne(roomNoQueryWrapper);
436
+            if (null == tpRoomNo) {
437
+                throw new WisdomException("编号: " + roomId + " 不是本小区的房产");
438
+            }
439
+            cell = getCell(row.getCell(1));
427
             if (null == cell) {
440
             if (null == cell) {
428
                 throw new WisdomException("第" + currentRow + "行 期/区 不能为空");
441
                 throw new WisdomException("第" + currentRow + "行 期/区 不能为空");
429
             }
442
             }
430
             String phase = cell.getStringCellValue().trim();
443
             String phase = cell.getStringCellValue().trim();
431
-            cell = getCell(row.getCell(1));
444
+            cell = getCell(row.getCell(2));
432
             if (null == cell) {
445
             if (null == cell) {
433
                 throw new WisdomException("第" + currentRow + "行 楼栋 不能为空");
446
                 throw new WisdomException("第" + currentRow + "行 楼栋 不能为空");
434
             }
447
             }
435
             String building = cell.getStringCellValue().trim();
448
             String building = cell.getStringCellValue().trim();
436
-            cell = getCell(row.getCell(2));
449
+            cell = getCell(row.getCell(3));
437
             if (null == cell) {
450
             if (null == cell) {
438
                 throw new WisdomException("第" + currentRow + "行 单元 不能为空");
451
                 throw new WisdomException("第" + currentRow + "行 单元 不能为空");
439
             }
452
             }
440
             String unit = cell.getStringCellValue().trim();
453
             String unit = cell.getStringCellValue().trim();
441
-            cell = getCell(row.getCell(3));
454
+            cell = getCell(row.getCell(4));
442
             if (null == cell) {
455
             if (null == cell) {
443
                 throw new WisdomException("第" + currentRow + "行 楼层 不能为空");
456
                 throw new WisdomException("第" + currentRow + "行 楼层 不能为空");
444
             }
457
             }
445
             String level = cell.getStringCellValue().trim();
458
             String level = cell.getStringCellValue().trim();
446
-            cell = getCell(row.getCell(4));
459
+            cell = getCell(row.getCell(5));
447
             if (null == cell) {
460
             if (null == cell) {
448
                 throw new WisdomException("第" + currentRow + "行 房号 不能为空");
461
                 throw new WisdomException("第" + currentRow + "行 房号 不能为空");
449
             }
462
             }
451
 
464
 
452
 
465
 
453
             // 收费说明可以为空
466
             // 收费说明可以为空
454
-            cell = getCell(row.getCell(5));
467
+            cell = getCell(row.getCell(6));
455
             String billExplain = null;
468
             String billExplain = null;
456
             if (null != cell) {
469
             if (null != cell) {
457
                 billExplain = cell.getStringCellValue().trim();
470
                 billExplain = cell.getStringCellValue().trim();
460
                 }
473
                 }
461
             }
474
             }
462
 
475
 
463
-            cell = getCell(row.getCell(6));
476
+            cell = getCell(row.getCell(7));
464
             if (null == cell) {
477
             if (null == cell) {
465
                 throw new WisdomException("第" + currentRow + "行 金额 不能为空");
478
                 throw new WisdomException("第" + currentRow + "行 金额 不能为空");
466
             }
479
             }
624
                 TpRoomNo tpRoomNo = records.get(index);
637
                 TpRoomNo tpRoomNo = records.get(index);
625
                 row = sheet.createRow(currentRow);
638
                 row = sheet.createRow(currentRow);
626
                 cell = row.createCell(0);
639
                 cell = row.createCell(0);
627
-                cell.setCellValue(tpRoomNo.getPhaseName());
640
+                cell.setCellValue(tpRoomNo.getId() + "");
628
                 cell = row.createCell(1);
641
                 cell = row.createCell(1);
629
-                cell.setCellValue(tpRoomNo.getBuildingName());
642
+                cell.setCellValue(tpRoomNo.getPhaseName());
630
                 cell = row.createCell(2);
643
                 cell = row.createCell(2);
631
-                cell.setCellValue(tpRoomNo.getUnitName());
644
+                cell.setCellValue(tpRoomNo.getBuildingName());
632
                 cell = row.createCell(3);
645
                 cell = row.createCell(3);
633
-                cell.setCellValue(tpRoomNo.getLevelName());
646
+                cell.setCellValue(tpRoomNo.getUnitName());
634
                 cell = row.createCell(4);
647
                 cell = row.createCell(4);
648
+                cell.setCellValue(tpRoomNo.getLevelName());
649
+                cell = row.createCell(5);
635
                 cell.setCellValue(tpRoomNo.getName());
650
                 cell.setCellValue(tpRoomNo.getName());
636
                 currentRow ++;
651
                 currentRow ++;
637
                 index ++;
652
                 index ++;

BIN
CODE/smart-community/property-api/src/main/resources/缴费单模板.xls View File


+ 1
- 1
VUECODE/smart-property-manage/config/dev.env.js View File

4
 
4
 
5
 module.exports = merge(prodEnv, {
5
 module.exports = merge(prodEnv, {
6
   NODE_ENV: '"development"',
6
   NODE_ENV: '"development"',
7
-  BASE_API: '"http://106.14.20.193:8086/property-api"',
7
+  BASE_API: '"http://localhost:8086/property-api"',
8
 })
8
 })

+ 16
- 5
VUECODE/smart-property-manage/src/views/bill/add/index.vue View File

27
             :before-upload="beforeUpload"
27
             :before-upload="beforeUpload"
28
             :data="ruleForm"
28
             :data="ruleForm"
29
             :action="uploadUrl"
29
             :action="uploadUrl"
30
+            :headers="uploadHeaders"
30
             name="file"
31
             name="file"
31
             class="upload-demo"
32
             class="upload-demo"
32
             multiple>
33
             multiple>
33
             <el-button slot="trigger" size="small" type="primary">选取账单文件并预览</el-button>
34
             <el-button slot="trigger" size="small" type="primary">选取账单文件并预览</el-button>
34
-        </el-upload>
35
+          </el-upload>
35
         </el-col>
36
         </el-col>
36
       </el-row>
37
       </el-row>
37
       <span style="color: #99a9bf; font-size: 13px;">如果想修改下表的内容,请重新下载excel模板填写金额后上传,系统会直接删除下表所有旧数据,以新的excel内容为准</span>
38
       <span style="color: #99a9bf; font-size: 13px;">如果想修改下表的内容,请重新下载excel模板填写金额后上传,系统会直接删除下表所有旧数据,以新的excel内容为准</span>
52
           <template slot-scope="scope">{{ showAddress(scope.row) }}</template>
53
           <template slot-scope="scope">{{ showAddress(scope.row) }}</template>
53
         </el-table-column>
54
         </el-table-column>
54
         <!--<el-table-column-->
55
         <!--<el-table-column-->
55
-          <!--prop="ownerName"-->
56
-          <!--label="户主姓名"/>-->
56
+        <!--prop="ownerName"-->
57
+        <!--label="户主姓名"/>-->
57
         <el-table-column
58
         <el-table-column
58
           prop="billExplain"
59
           prop="billExplain"
59
           align="center"
60
           align="center"
85
 import { mapState, mapActions, mapMutations } from 'vuex'
86
 import { mapState, mapActions, mapMutations } from 'vuex'
86
 import waves from '@/directive/waves' // Waves directive
87
 import waves from '@/directive/waves' // Waves directive
87
 import { parseTime } from '@/utils'
88
 import { parseTime } from '@/utils'
88
-
89
+import { getToken } from '@/utils/auth'
89
 export default {
90
 export default {
90
   computed: {
91
   computed: {
91
     ...mapState('role', {
92
     ...mapState('role', {
123
       total: 0,
124
       total: 0,
124
       list: [], // 数据
125
       list: [], // 数据
125
       tempList: [], // 临时数据
126
       tempList: [], // 临时数据
126
-      files: '' // 文件
127
+      files: '', // 文件
128
+      uploadHeaders: { // 上传文件的请求头
129
+        'X-Auth-Token': getToken()
130
+      }
127
     }
131
     }
128
   },
132
   },
129
   created() {
133
   created() {
169
         this.$message.error(response.message)
173
         this.$message.error(response.message)
170
         return
174
         return
171
       }
175
       }
176
+      this.listQuery.pageNum = 1
177
+      this.listQuery.pageSize = 10
172
       this.tempList = response.data.list
178
       this.tempList = response.data.list
173
       this.total = response.data.total
179
       this.total = response.data.total
174
       this.list = this.getList()
180
       this.list = this.getList()
312
         console.log('error BillDownloadExcel')
318
         console.log('error BillDownloadExcel')
313
       })
319
       })
314
     }
320
     }
321
+    // uploadHeaders() { // 设置文件上传的请求头
322
+    //   const uploadHeaders = { 'X-Auth-Token': this.token }
323
+    //   console.log('上传缴费单Token: ', uploadHeaders)
324
+    //   return uploadHeaders
325
+    // }
315
   }
326
   }
316
 }
327
 }
317
 </script>
328
 </script>