Selaa lähdekoodia

修复 bug 4442

魏熙美 6 vuotta sitten
vanhempi
commit
62634834b1

+ 3
- 2
CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/BillController.java Näytä tiedosto

@@ -80,9 +80,10 @@ public class BillController extends BaseController {
80 80
 
81 81
     @ApiOperation(value = "上传缴费项接口, 预览", notes = "上传缴费项接口, 预览")
82 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 84
         ResponseBean responseBean = new ResponseBean();
85
-        responseBean = iBillService.getExcelData(file);
85
+        UserElement userElement = getUserElement(session);
86
+        responseBean = iBillService.getExcelData(file, userElement);
86 87
         return responseBean;
87 88
     }
88 89
 

+ 1
- 1
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/IBillService.java Näytä tiedosto

@@ -49,7 +49,7 @@ public interface IBillService extends IService<Bill> {
49 49
 	 * @param file
50 50
 	 * @return
51 51
 	 */
52
-    ResponseBean getExcelData(MultipartFile file);
52
+    ResponseBean getExcelData(MultipartFile file,  UserElement userElement);
53 53
 
54 54
 	/**
55 55
 	 * 上传excel, 解析 入库

+ 40
- 25
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/BillServiceImpl.java Näytä tiedosto

@@ -158,14 +158,14 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
158 158
 
159 159
     @Override
160 160
     @Transactional(rollbackFor = Exception.class)
161
-    public ResponseBean getExcelData(MultipartFile file) {
161
+    public ResponseBean getExcelData(MultipartFile file, UserElement userElement) {
162 162
         ResponseBean responseBean = new ResponseBean();
163 163
         if (file == null) {
164 164
             responseBean.addError("对象不能为空");
165 165
             return responseBean;
166 166
         }
167 167
 
168
-        responseBean = getExcelData(file, responseBean);
168
+        responseBean = getExcelData(file, responseBean, userElement.getCommunityId());
169 169
         List<TempBill> tempBills = (List<TempBill>) responseBean.getData();
170 170
 
171 171
         Map<String, Object> map = Maps.newHashMap();
@@ -213,7 +213,7 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
213 213
             return responseBean;
214 214
         }
215 215
 
216
-        responseBean = getExcelData(file, responseBean);
216
+        responseBean = getExcelData(file, responseBean, userElement.getCommunityId());
217 217
         List<TempBill> tempBills = (List<TempBill>) responseBean.getData();
218 218
 
219 219
         Double sumDouble = 0.0;
@@ -273,9 +273,18 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
273 273
         // int rows = billMapper.insert(bill);
274 274
         boolean b = this.saveOrUpdate(bill);
275 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 288
                 message.setCommunityId(userElement.getCommunityId());
280 289
                 message.setMessageType("7");
281 290
                 message.setAdviceType("4");
@@ -295,14 +304,6 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
295 304
             }
296 305
             // 发布时消息为无效
297 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 307
                 if (null != message) {
307 308
                     message.setStatus("0");
308 309
                     message.setUpdateDate(LocalDateTime.now());
@@ -310,7 +311,6 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
310 311
                     messageMapper.updateById(message);
311 312
                 }
312 313
 
313
-
314 314
                 // 插入消息表, 消息类型为 消息
315 315
                 Message messageModel = new Message();
316 316
                 messageModel.setCommunityId(userElement.getCommunityId());
@@ -390,7 +390,7 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
390 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 396
         List<TempBill> tempBills = Lists.newArrayList();
@@ -424,26 +424,39 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
424 424
             int currentRow = i + 1;
425 425
             Row row = sheetAt.getRow(i);
426 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 440
             if (null == cell) {
428 441
                 throw new WisdomException("第" + currentRow + "行 期/区 不能为空");
429 442
             }
430 443
             String phase = cell.getStringCellValue().trim();
431
-            cell = getCell(row.getCell(1));
444
+            cell = getCell(row.getCell(2));
432 445
             if (null == cell) {
433 446
                 throw new WisdomException("第" + currentRow + "行 楼栋 不能为空");
434 447
             }
435 448
             String building = cell.getStringCellValue().trim();
436
-            cell = getCell(row.getCell(2));
449
+            cell = getCell(row.getCell(3));
437 450
             if (null == cell) {
438 451
                 throw new WisdomException("第" + currentRow + "行 单元 不能为空");
439 452
             }
440 453
             String unit = cell.getStringCellValue().trim();
441
-            cell = getCell(row.getCell(3));
454
+            cell = getCell(row.getCell(4));
442 455
             if (null == cell) {
443 456
                 throw new WisdomException("第" + currentRow + "行 楼层 不能为空");
444 457
             }
445 458
             String level = cell.getStringCellValue().trim();
446
-            cell = getCell(row.getCell(4));
459
+            cell = getCell(row.getCell(5));
447 460
             if (null == cell) {
448 461
                 throw new WisdomException("第" + currentRow + "行 房号 不能为空");
449 462
             }
@@ -451,7 +464,7 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
451 464
 
452 465
 
453 466
             // 收费说明可以为空
454
-            cell = getCell(row.getCell(5));
467
+            cell = getCell(row.getCell(6));
455 468
             String billExplain = null;
456 469
             if (null != cell) {
457 470
                 billExplain = cell.getStringCellValue().trim();
@@ -460,7 +473,7 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
460 473
                 }
461 474
             }
462 475
 
463
-            cell = getCell(row.getCell(6));
476
+            cell = getCell(row.getCell(7));
464 477
             if (null == cell) {
465 478
                 throw new WisdomException("第" + currentRow + "行 金额 不能为空");
466 479
             }
@@ -624,14 +637,16 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
624 637
                 TpRoomNo tpRoomNo = records.get(index);
625 638
                 row = sheet.createRow(currentRow);
626 639
                 cell = row.createCell(0);
627
-                cell.setCellValue(tpRoomNo.getPhaseName());
640
+                cell.setCellValue(tpRoomNo.getId() + "");
628 641
                 cell = row.createCell(1);
629
-                cell.setCellValue(tpRoomNo.getBuildingName());
642
+                cell.setCellValue(tpRoomNo.getPhaseName());
630 643
                 cell = row.createCell(2);
631
-                cell.setCellValue(tpRoomNo.getUnitName());
644
+                cell.setCellValue(tpRoomNo.getBuildingName());
632 645
                 cell = row.createCell(3);
633
-                cell.setCellValue(tpRoomNo.getLevelName());
646
+                cell.setCellValue(tpRoomNo.getUnitName());
634 647
                 cell = row.createCell(4);
648
+                cell.setCellValue(tpRoomNo.getLevelName());
649
+                cell = row.createCell(5);
635 650
                 cell.setCellValue(tpRoomNo.getName());
636 651
                 currentRow ++;
637 652
                 index ++;

BIN
CODE/smart-community/property-api/src/main/resources/缴费单模板.xls Näytä tiedosto


+ 1
- 1
VUECODE/smart-property-manage/config/dev.env.js Näytä tiedosto

@@ -4,5 +4,5 @@ const prodEnv = require('./prod.env')
4 4
 
5 5
 module.exports = merge(prodEnv, {
6 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 Näytä tiedosto

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