|
@@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
5
|
5
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
6
|
6
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
7
|
7
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
8
|
+import com.google.common.collect.Lists;
|
|
9
|
+import com.google.common.collect.Maps;
|
8
|
10
|
import com.huiju.estateagents.base.ResponseBean;
|
9
|
|
-import com.huiju.estateagents.center.taUser.mapper.TaUserMapper;
|
|
11
|
+import com.huiju.estateagents.center.taUser.entity.TaUser;
|
10
|
12
|
import com.huiju.estateagents.property.common.Constant;
|
11
|
13
|
import com.huiju.estateagents.property.dao.*;
|
12
|
14
|
import com.huiju.estateagents.property.model.*;
|
|
@@ -15,11 +17,12 @@ import com.huiju.estateagents.property.vo.TpTicketVO;
|
15
|
17
|
import org.springframework.beans.BeanUtils;
|
16
|
18
|
import org.springframework.beans.factory.annotation.Autowired;
|
17
|
19
|
import org.springframework.stereotype.Service;
|
|
20
|
+import org.springframework.transaction.annotation.Transactional;
|
18
|
21
|
|
|
22
|
+import java.io.IOException;
|
19
|
23
|
import java.time.LocalDateTime;
|
20
|
|
-import java.util.ArrayList;
|
21
|
|
-import java.util.HashMap;
|
22
|
|
-import java.util.List;
|
|
24
|
+import java.time.ZoneId;
|
|
25
|
+import java.util.*;
|
23
|
26
|
|
24
|
27
|
/**
|
25
|
28
|
* <p>
|
|
@@ -47,9 +50,6 @@ public class TpTicketServiceImpl extends ServiceImpl<TpTicketMapper, TpTicket> i
|
47
|
50
|
@Autowired
|
48
|
51
|
private TpTicketRecordCommentMapper tpTicketRecordCommentMapper;
|
49
|
52
|
|
50
|
|
-// @Autowired
|
51
|
|
-// private TaUserMapper taUserMapper;
|
52
|
|
-
|
53
|
53
|
@Autowired
|
54
|
54
|
private MessageMapper messageMapper;
|
55
|
55
|
|
|
@@ -114,9 +114,9 @@ public class TpTicketServiceImpl extends ServiceImpl<TpTicketMapper, TpTicket> i
|
114
|
114
|
/*查询当前受理人*/
|
115
|
115
|
ticketVO.setTpUserNmae(userMapper.selectByIdUserName(ticketVO.getTpUserId()));
|
116
|
116
|
/*所有物业端本小区的人员*/
|
117
|
|
- ticketVO.setUserList(userMapper.getUser( userID,orgId));
|
|
117
|
+ ticketVO.setTpUsersList(userMapper.getUser( userID,orgId));
|
118
|
118
|
/*本人*/
|
119
|
|
- ticketVO.setCurrentUserName(userID);
|
|
119
|
+ ticketVO.setCurrentUserName(userID.toString());
|
120
|
120
|
|
121
|
121
|
|
122
|
122
|
/*查询工单类容的图片*/
|
|
@@ -426,4 +426,538 @@ public class TpTicketServiceImpl extends ServiceImpl<TpTicketMapper, TpTicket> i
|
426
|
426
|
response.addSuccess("成功");
|
427
|
427
|
return response;
|
428
|
428
|
}
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+ @Override
|
|
432
|
+ public ResponseBean getList(TpTicket tpTicket, Integer pageNum, Integer pageSize) {
|
|
433
|
+
|
|
434
|
+ ResponseBean<Map<String, Object>> responseBean = new ResponseBean();
|
|
435
|
+ // 最终返回值
|
|
436
|
+ Map<String, Object> result = Maps.newHashMap();
|
|
437
|
+
|
|
438
|
+ Map<String, Object> parameter = Maps.newHashMap();
|
|
439
|
+ parameter.put("communityId", tpTicket.getOrgId());
|
|
440
|
+ parameter.put("taUserId", tpTicket.getTaUserId());
|
|
441
|
+
|
|
442
|
+ // 1:投诉 2:报修 3:联系物业
|
|
443
|
+ parameter.put("type", 2);
|
|
444
|
+ // 报修
|
|
445
|
+ Page<TpTicket> pageRepairs = new Page(pageNum, pageSize);
|
|
446
|
+ IPage<TpTicket> tpTicketIPage = tpTicketMapper.selectByCommuniytIdAndByTaUserIdAndByType(pageRepairs, parameter);
|
|
447
|
+ List<TpTicket> tpTicketRepairsList = tpTicketIPage.getRecords();
|
|
448
|
+ List<TpTicketVO> repairsList = Lists.newArrayList();
|
|
449
|
+ tpTicketVOConvert(tpTicketRepairsList, repairsList);
|
|
450
|
+
|
|
451
|
+ // 投诉
|
|
452
|
+ // 1:投诉 2:报修 3:联系物业
|
|
453
|
+ parameter.put("type", 1);
|
|
454
|
+ Page<TpTicket> pageComplaint = new Page(pageNum, pageSize);
|
|
455
|
+ IPage<TpTicket> tpTicketIPageComplaint = tpTicketMapper.selectByCommuniytIdAndByTaUserIdAndByType(pageComplaint, parameter);
|
|
456
|
+ List<TpTicket> tpTicketComplaintList = tpTicketIPageComplaint.getRecords();
|
|
457
|
+ List<TpTicketVO> complaintList = Lists.newArrayList();
|
|
458
|
+ tpTicketVOConvert(tpTicketComplaintList, complaintList);
|
|
459
|
+
|
|
460
|
+ // 联系工单
|
|
461
|
+ // 1:投诉 2:报修 3:联系物业
|
|
462
|
+ parameter.put("type", 3);
|
|
463
|
+ Page<TpTicket> pageLiaison = new Page(pageNum, pageSize);
|
|
464
|
+ IPage<TpTicket> tpTicketIPageLiaison = tpTicketMapper.selectByCommuniytIdAndByTaUserIdAndByType(pageLiaison, parameter);
|
|
465
|
+ List<TpTicket> tpTicketLiaisonList = tpTicketIPageLiaison.getRecords();
|
|
466
|
+ List<TpTicketVO> liaisonList = Lists.newArrayList();
|
|
467
|
+ tpTicketVOConvert(tpTicketLiaisonList, liaisonList);
|
|
468
|
+ Long[] arr = new Long[]{pageComplaint.getTotal(), pageLiaison.getTotal(), pageRepairs.getTotal()};
|
|
469
|
+ Arrays.sort(arr);
|
|
470
|
+ result.put("repairs", repairsList);
|
|
471
|
+ result.put("complaint", complaintList);
|
|
472
|
+ result.put("liaison", liaisonList);
|
|
473
|
+ result.put("total", arr[2]);
|
|
474
|
+
|
|
475
|
+ responseBean.addSuccess(result);
|
|
476
|
+ return responseBean;
|
|
477
|
+ }
|
|
478
|
+
|
|
479
|
+ /**
|
|
480
|
+ * 公共方法, 获取一条数据
|
|
481
|
+ *
|
|
482
|
+ * @param map
|
|
483
|
+ * @return
|
|
484
|
+ */
|
|
485
|
+ private TpTicketRecordComment getTicketRecordComment(Map map) {
|
|
486
|
+ List<TpTicketRecordComment> list = tpTicketRecordCommentMapper.selectByTicketId(map);
|
|
487
|
+ return null == list
|
|
488
|
+ ? null : list.size() == 0
|
|
489
|
+ ? null : list.get(0);
|
|
490
|
+ }
|
|
491
|
+
|
|
492
|
+ /**
|
|
493
|
+ * 数据转换,并填充数据
|
|
494
|
+ *
|
|
495
|
+ * @param target
|
|
496
|
+ * @param source
|
|
497
|
+ * @return
|
|
498
|
+ */
|
|
499
|
+ public void tpTicketVOConvert(List<TpTicket> source, List<TpTicketVO> target) {
|
|
500
|
+
|
|
501
|
+ // 获取联系号码簿(物业号码)
|
|
502
|
+ // List<TpannouncementTel> tpannouncementTel = tpannouncementTelMapper.getTpannouncementTel();
|
|
503
|
+
|
|
504
|
+ // 查询参数
|
|
505
|
+ Map<String, Object> lastRecordMap = Maps.newHashMap();
|
|
506
|
+ // 表示查询出最新的一条
|
|
507
|
+ lastRecordMap.put("size", 1);
|
|
508
|
+
|
|
509
|
+ source.stream().forEach(e -> {
|
|
510
|
+ TpTicketVO tpTicketVO = new TpTicketVO();
|
|
511
|
+ BeanUtils.copyProperties(e, tpTicketVO);
|
|
512
|
+ // 设置工单编号
|
|
513
|
+ lastRecordMap.put("tickerId", e.getId());
|
|
514
|
+ TpTicketRecordComment comment = getTicketRecordComment(lastRecordMap);
|
|
515
|
+ List<TpTicketRecord> recordList = tpTicketRecordMapper.getTicketRecordByTicketId(e.getOrgId() + "", e.getId());
|
|
516
|
+ // 报修类型:0:公共区域 1: 房屋质量 2::户内设施 PS : 报修的情况下才有报修类型
|
|
517
|
+ String repairType = e.getRepairType();
|
|
518
|
+ String repairName = repairType == null ?
|
|
519
|
+ null : "0".equals(repairType) ?
|
|
520
|
+ "公共区域" : "1".equals(repairType) ?
|
|
521
|
+ "房屋质量" : "2".equals(repairType) ?
|
|
522
|
+ "户内设施" : null;
|
|
523
|
+ tpTicketVO.setRepairName(repairName);
|
|
524
|
+ tpTicketVO.setStatus(recordList.get(recordList.size() - 1).getStatus());
|
|
525
|
+ tpTicketVO.setTicketStatusName(recordList.get(recordList.size() - 1).getTicketStatusName());
|
|
526
|
+ tpTicketVO.setTicketRecordDate(Date.from(recordList.get(recordList.size() - 1).getCreateDate().atZone(ZoneId.systemDefault()).toInstant()));
|
|
527
|
+ tpTicketVO.setTicketStatusContent(recordList.get(recordList.size() - 1).getContent());
|
|
528
|
+ if (null != comment) {
|
|
529
|
+ tpTicketVO.setCommentContent(comment.getContent());
|
|
530
|
+ tpTicketVO.setCommentCreateDate(Date.from(comment.getCreateDate().atZone(ZoneId.systemDefault()).toInstant()));
|
|
531
|
+ }
|
|
532
|
+
|
|
533
|
+// // 0:待分配 1:拒绝受理 2:待处理 3:正在处理 4:待评价 5:已评价 6:被终止
|
|
534
|
+//
|
|
535
|
+// // 0:待分配 需要出现物业号码簿
|
|
536
|
+// if ("0".equals(e.getStatus())) {
|
|
537
|
+// Map<String, Object> map = Maps.newHashMap();
|
|
538
|
+// map.put("message","联系物业号码簿");
|
|
539
|
+// map.put("data",tpannouncementTel);
|
|
540
|
+// tpTicketVO.setContactBook(map);
|
|
541
|
+// }
|
|
542
|
+
|
|
543
|
+ target.add(tpTicketVO);
|
|
544
|
+ });
|
|
545
|
+ }
|
|
546
|
+
|
|
547
|
+ @Override
|
|
548
|
+ public ResponseBean getByTypeList(TpTicket tpTicket, Integer pageNum, Integer pageSize) {
|
|
549
|
+
|
|
550
|
+ ResponseBean response = new ResponseBean();
|
|
551
|
+
|
|
552
|
+ Map<String, Object> parameter = Maps.newHashMap();
|
|
553
|
+ parameter.put("communityId", tpTicket.getOrgId());
|
|
554
|
+ parameter.put("taUserId", tpTicket.getTaUserId());
|
|
555
|
+
|
|
556
|
+ // 1:投诉 2:报修 3:联系物业
|
|
557
|
+ parameter.put("type", tpTicket.getType());
|
|
558
|
+
|
|
559
|
+ Page<TpTicket> pagelist = new Page<>(pageNum, pageSize);
|
|
560
|
+ IPage<TpTicket> tpTicketIPage = tpTicketMapper.selectByCommuniytIdAndByTaUserIdAndByType(pagelist, parameter);
|
|
561
|
+ List<TpTicket> tpTicketList = tpTicketIPage.getRecords();
|
|
562
|
+
|
|
563
|
+ List<TpTicketVO> tpTicketVOList = Lists.newArrayList();
|
|
564
|
+ tpTicketVOConvert(tpTicketList, tpTicketVOList);
|
|
565
|
+ Map<String, Object> map = Maps.newHashMap();
|
|
566
|
+ map.put("pagelist", tpTicketVOList);
|
|
567
|
+ map.put("total", pagelist.getTotal());
|
|
568
|
+
|
|
569
|
+ response.addSuccess(map);
|
|
570
|
+
|
|
571
|
+ return response;
|
|
572
|
+ }
|
|
573
|
+
|
|
574
|
+ /**
|
|
575
|
+ * 获取报修详情
|
|
576
|
+ *
|
|
577
|
+ * @param orgId
|
|
578
|
+ * @param ticketId
|
|
579
|
+ * @return
|
|
580
|
+ */
|
|
581
|
+ @Override
|
|
582
|
+ @Transactional(rollbackFor = Exception.class)
|
|
583
|
+ public TpTicket getTicketSchedule(String orgId, Integer ticketId) {
|
|
584
|
+ //查看工单详情
|
|
585
|
+ TpTicket ticket = tpTicketMapper.selectById(ticketId);
|
|
586
|
+ if (null != ticket) {
|
|
587
|
+ //工单进度
|
|
588
|
+ List<TpTicketRecord> ticketRecordList = tpTicketRecordMapper.getTicketRecordByTicketId(orgId, ticketId);
|
|
589
|
+ //工单回复
|
|
590
|
+ ticketRecordList.stream().forEach(tpTicketRecord -> {
|
|
591
|
+ List<TpTicketRecordComment> ticketRecordCommentList = tpTicketRecordCommentMapper.selectByTicketRecordId(tpTicketRecord);
|
|
592
|
+ //遍历工单下每条对话信息的id去查对话图片
|
|
593
|
+ for (TpTicketRecordComment tpTicketRecordComment : ticketRecordCommentList) {
|
|
594
|
+ Map<String, Object> map = Maps.newHashMap();
|
|
595
|
+ map.put("uuid", tpTicketRecordComment.getId());
|
|
596
|
+ map.put("type", "reply");
|
|
597
|
+ List<TdImages> tdImagesList = tdImagesMapper.getByUUIDAndByType(map);
|
|
598
|
+ tpTicketRecordComment.setImgURL(tdImagesList);
|
|
599
|
+ }
|
|
600
|
+ tpTicketRecord.setTicketRecordCommentList(ticketRecordCommentList);
|
|
601
|
+ });
|
|
602
|
+
|
|
603
|
+ Map<String, Object> map = Maps.newHashMap();
|
|
604
|
+ map.put("uuid", ticket.getId());
|
|
605
|
+ map.put("type", "service");
|
|
606
|
+ List<TdImages> tdImagesList = tdImagesMapper.getByUUIDAndByType(map);
|
|
607
|
+
|
|
608
|
+ // 图片数组
|
|
609
|
+ String[] imgageArr = new String[tdImagesList.size()];
|
|
610
|
+
|
|
611
|
+ for (int i = 0; i < tdImagesList.size(); i++) {
|
|
612
|
+ imgageArr[i] = tdImagesList.get(i).getImageUrl();
|
|
613
|
+ }
|
|
614
|
+
|
|
615
|
+ ticket.setTdImagesList(imgageArr);
|
|
616
|
+ ticket.setTicketRecordList(ticketRecordList);
|
|
617
|
+
|
|
618
|
+// // 把该工单的消息变为 已读
|
|
619
|
+// TpMessage tpMessage = new TpMessage();
|
|
620
|
+// tpMessage.setSource("1");
|
|
621
|
+// tpMessage.setModelType("1");
|
|
622
|
+// tpMessage.setMessageType(ticket.getType());
|
|
623
|
+//
|
|
624
|
+// tpMessage = tpMessageMapper.selectTicketMessage(tpMessage);
|
|
625
|
+// tpMessage.setReadStatus("1");
|
|
626
|
+//
|
|
627
|
+// // 变为已读
|
|
628
|
+// tpMessageMapper.updateByPrimaryKeySelective(tpMessage);
|
|
629
|
+
|
|
630
|
+ }
|
|
631
|
+ return ticket;
|
|
632
|
+ }
|
|
633
|
+
|
|
634
|
+ @Override
|
|
635
|
+ @Transactional(rollbackFor = Exception.class)
|
|
636
|
+ public ResponseBean addAiTicketService(TaUser userElement, String parameter) throws IOException {
|
|
637
|
+ ResponseBean response = new ResponseBean();
|
|
638
|
+ JSONObject jsonObject = JSONObject.parseObject(parameter);
|
|
639
|
+ String imageUrl = (String) jsonObject.get("imageUrl");
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+ TpTicket tpTicket = JSONObject.parseObject(parameter, TpTicket.class);
|
|
643
|
+
|
|
644
|
+ /**
|
|
645
|
+ * 工单表 -> 工单处理表 -> 消息表
|
|
646
|
+ * 依次插入相关数据, 该工单默认的第一条数据(待分配), 是工单标题,
|
|
647
|
+ */
|
|
648
|
+
|
|
649
|
+ tpTicket.setOrgId(userElement.getOrgId());
|
|
650
|
+ // 2.1以后为ta_user_verify为中心不再是已用户ta_user为中心
|
|
651
|
+ tpTicket.setTaUserId(userElement.getUserId());
|
|
652
|
+ // 默认待分配
|
|
653
|
+ tpTicket.setStatus("0");
|
|
654
|
+ // 2.1以后为ta_user_verify为中心不再是已用户ta_user为中心
|
|
655
|
+ tpTicket.setCreateUser(userElement.getUserId());
|
|
656
|
+ tpTicket.setCreateDate(LocalDateTime.now());
|
|
657
|
+ tpTicket.setUpdateUser(userElement.getUserId());
|
|
658
|
+ //tpTicket.setUpdateDate(new Date());
|
|
659
|
+ //校验此工单是否已存在
|
|
660
|
+ TpTicket tpTicketName= tpTicketMapper.selectTpTicketName(userElement.getOrgId(),tpTicket.getType(),tpTicket.getTicketTitle());
|
|
661
|
+ if (null != tpTicketName){
|
|
662
|
+ response.addError("工单已存在");
|
|
663
|
+ return response;
|
|
664
|
+ }
|
|
665
|
+ // 插入工单
|
|
666
|
+ tpTicketMapper.insert(tpTicket);
|
|
667
|
+ insertTdImage(tpTicket, imageUrl, userElement.getUserId());
|
|
668
|
+
|
|
669
|
+ Integer id = tpTicket.getId();
|
|
670
|
+ TpTicketRecord tpTicketRecord = new TpTicketRecord();
|
|
671
|
+ //获取当前插入的信息,维护工单记录表
|
|
672
|
+ TpTicket tpTicketReco = tpTicketMapper.selectById(id);
|
|
673
|
+ tpTicketRecord.setOrgId(userElement.getOrgId());
|
|
674
|
+ tpTicketRecord.setTicketId(tpTicketReco.getId());
|
|
675
|
+ // 1:投诉 2:报修 3:联系物业
|
|
676
|
+ String typeName = "2".equals(tpTicket.getType()) ? "报修" : "1".equals(tpTicket.getType()) ? "投诉" : "3".equals(tpTicket.getType()) ? "联系工单" : "未知类型";
|
|
677
|
+ tpTicketRecord.setContent("您的" + typeName + "正在分配物业处理人员, 若长时间无人处理, 请联系物业! 联系物业号码簿 >");
|
|
678
|
+ tpTicketRecord.setStatus(tpTicketReco.getStatus());
|
|
679
|
+ tpTicketRecord.setCreateUser(userElement.getUserId());
|
|
680
|
+ tpTicketRecord.setCreateDate(LocalDateTime.now());
|
|
681
|
+ // 插入工单处理表
|
|
682
|
+ tpTicketRecordMapper.insert(tpTicketRecord);
|
|
683
|
+ // 推物业端,推这个小区下的所有管理员
|
|
684
|
+// List<TpUser> tpUserList= tpUserMapper.selectCommunityId(userElement.getOrgId());
|
|
685
|
+// for (TpUser tpUser:tpUserList) {
|
|
686
|
+// Map<String, Object> mapProp = new HashMap<>();
|
|
687
|
+// mapProp.put("communityId", userElement.getOrgId());
|
|
688
|
+// mapProp.put("createUserId", userElement.getUserVerifyId());
|
|
689
|
+// mapProp.put("ticketId", tpTicket.getId());
|
|
690
|
+// mapProp.put("title", tpTicket.getTicketTitle());
|
|
691
|
+// mapProp.put("name", userElement.getUserName());
|
|
692
|
+// mapProp.put("tpUserId", tpUser.getId());
|
|
693
|
+// applicationContext.publishEvent(new MessageEvent(mapProp, Constant.TICKET_ADD, mapProp));
|
|
694
|
+// }
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+ response.addSuccess(tpTicketReco);
|
|
698
|
+ return response;
|
|
699
|
+ }
|
|
700
|
+
|
|
701
|
+ /**
|
|
702
|
+ * 存入图片
|
|
703
|
+ *
|
|
704
|
+ * @param tpTicket
|
|
705
|
+ * @param imageUrl
|
|
706
|
+ * @param userId
|
|
707
|
+ * @throws IOException
|
|
708
|
+ */
|
|
709
|
+ private void insertTdImage(TpTicket tpTicket, String imageUrl, Integer userId) {
|
|
710
|
+ if (null == imageUrl || "".equals(imageUrl)) {
|
|
711
|
+ return;
|
|
712
|
+ }
|
|
713
|
+ String[] imgArr = imageUrl.split(",");
|
|
714
|
+ for (String img : imgArr) {
|
|
715
|
+ TdImages tdImages = new TdImages();
|
|
716
|
+ Integer uuId = tpTicket.getId();
|
|
717
|
+ tdImages.setImageUrl(img);
|
|
718
|
+ tdImages.setType(Constant.SERVICE);
|
|
719
|
+ tdImages.setUuid(uuId);
|
|
720
|
+ tdImages.setCreateUser(userId);
|
|
721
|
+ tdImages.setCreateTime(LocalDateTime.now());
|
|
722
|
+ tdImagesMapper.insert(tdImages);
|
|
723
|
+ }
|
|
724
|
+
|
|
725
|
+ }
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+ /**
|
|
729
|
+ * 回复工单
|
|
730
|
+ *
|
|
731
|
+ * @param tpTicketRecordComment
|
|
732
|
+ * @return
|
|
733
|
+ */
|
|
734
|
+ @Override
|
|
735
|
+ public Integer updateTicketsReply(TpTicketRecordComment tpTicketRecordComment, Integer userId) {
|
|
736
|
+ //查询用户名
|
|
737
|
+ User taUser = userMapper.selectById(userId);
|
|
738
|
+
|
|
739
|
+ TpTicket tpTicket= tpTicketMapper.selectById(tpTicketRecordComment.getTicketId());
|
|
740
|
+ TpTicketRecord ticketRecord= tpTicketRecordMapper.selectTpTicketRecord(tpTicketRecordComment.getTicketId(), Integer.valueOf(tpTicket.getStatus()));
|
|
741
|
+
|
|
742
|
+ tpTicketRecordComment.setUserName(taUser.getUserName());
|
|
743
|
+ tpTicketRecordComment.setParentId(tpTicketRecordComment.getId());
|
|
744
|
+ tpTicketRecordComment.setUuid(userId);
|
|
745
|
+ tpTicketRecordComment.setTicketRecordId(ticketRecord.getId());
|
|
746
|
+ tpTicketRecordComment.setUserType(Constant.TICKET_USER_TYPE);
|
|
747
|
+ tpTicketRecordComment.setCreateDate(LocalDateTime.now());
|
|
748
|
+ //插入回复数据
|
|
749
|
+ return tpTicketRecordCommentMapper.insert(tpTicketRecordComment);
|
|
750
|
+
|
|
751
|
+ }
|
|
752
|
+
|
|
753
|
+ @Override
|
|
754
|
+ @Transactional(rollbackFor = Exception.class)
|
|
755
|
+ public ResponseBean updateTicketContent(Integer ticketId, String parameter, TaUser userElement) {
|
|
756
|
+ ResponseBean responseBean = new ResponseBean();
|
|
757
|
+
|
|
758
|
+ JSONObject jsonObject = JSONObject.parseObject(parameter);
|
|
759
|
+ String imageUrl = (String) jsonObject.get("imageUrl");
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+ TpTicket tpTicket = JSONObject.parseObject(parameter, TpTicket.class);
|
|
763
|
+
|
|
764
|
+ // 删除旧图片链接
|
|
765
|
+ Map<String, Object> map = Maps.newHashMap();
|
|
766
|
+ map.put("uuid", ticketId);
|
|
767
|
+ map.put("type", "service");
|
|
768
|
+ tdImagesMapper.deleteByUuidAndType(map);
|
|
769
|
+
|
|
770
|
+ insertTdImage(tpTicket, imageUrl, userElement.getUserId());
|
|
771
|
+
|
|
772
|
+ TpTicket ticket = tpTicketMapper.selectById(ticketId);
|
|
773
|
+ ticket.setTicketTitle(tpTicket.getTicketTitle());
|
|
774
|
+ ticket.setTicketContent(tpTicket.getTicketContent());
|
|
775
|
+
|
|
776
|
+ tpTicketMapper.updateById(ticket);
|
|
777
|
+ // 维护1.5版本消息
|
|
778
|
+// Integer messageTicket= tpMessageMapper.selectTicket(ticketId);
|
|
779
|
+// if (!"".equals(messageTicket)) {
|
|
780
|
+// TpMessage tpMessage = new TpMessage();
|
|
781
|
+// tpMessage.setMessageContent("工单“" + tpTicket.getTicketTitle() + "”已被分配给您,点击查看并处理");
|
|
782
|
+// tpMessage.setUpdateDate(new Date());
|
|
783
|
+// tpMessage.setUpdateUser(userElement.getUserVerifyId());
|
|
784
|
+// tpMessageMapper.updateTickMessage(tpMessage);
|
|
785
|
+// }
|
|
786
|
+ // 修改消息以后推送物业端
|
|
787
|
+ // 推物业端,推这个小区下的所有管理员
|
|
788
|
+// List<TpUser> tpUserList= tpUserMapper.selectCommunityId(ticket.getOrgId());
|
|
789
|
+// for (TpUser tpUser:tpUserList) {
|
|
790
|
+// Map<String, Object> mapProp = new HashMap<>();
|
|
791
|
+// mapProp.put("communityId", ticket.getOrgId());
|
|
792
|
+// mapProp.put("createUserId", userElement.getUserVerifyId());
|
|
793
|
+// mapProp.put("ticketId", ticketId);
|
|
794
|
+// mapProp.put("title", tpTicket.getTicketTitle());
|
|
795
|
+// mapProp.put("name", userElement.getUserName());
|
|
796
|
+// mapProp.put("tpUserId", tpUser.getId());
|
|
797
|
+// applicationContext.publishEvent(new MessageEvent(mapProp, Constant.TICKET_UPDATE, mapProp));
|
|
798
|
+// }
|
|
799
|
+ responseBean.addSuccess("操作成功!");
|
|
800
|
+ return responseBean;
|
|
801
|
+ }
|
|
802
|
+
|
|
803
|
+ @Transactional(rollbackFor = Exception.class)
|
|
804
|
+ @Override
|
|
805
|
+ public ResponseBean stopTpTicketRecord(Integer orgId, Integer ticketId, TaUser userElement) {
|
|
806
|
+ ResponseBean responseBean = new ResponseBean();
|
|
807
|
+ try {
|
|
808
|
+ TpTicket tpTicket = new TpTicket();
|
|
809
|
+ tpTicket.setStatus("6");
|
|
810
|
+ tpTicket.setId(ticketId);
|
|
811
|
+ tpTicketMapper.updateById(tpTicket);
|
|
812
|
+ //根据1.4版本需要被终止时,清空当前工单受理人
|
|
813
|
+ tpTicketMapper.updateTpUserId(ticketId);
|
|
814
|
+
|
|
815
|
+ TpTicketRecord tpTicketRecord = new TpTicketRecord();
|
|
816
|
+ tpTicketRecord.setStatus("6");
|
|
817
|
+ tpTicketRecord.setTicketId(ticketId);
|
|
818
|
+ tpTicketRecord.setOrgId(orgId);
|
|
819
|
+
|
|
820
|
+ tpTicketRecord.setContent("您的联系单已被您自己终止,如果仍有问题,可以在服务页新增一个报修/投诉/联系单");
|
|
821
|
+ tpTicketRecord.setCreateUser(userElement.getUserId());
|
|
822
|
+ tpTicketRecord.setCreateDate(LocalDateTime.now());
|
|
823
|
+ tpTicketRecordMapper.insert(tpTicketRecord);
|
|
824
|
+ // 终止后维护tp_ticket_record_comment对话
|
|
825
|
+ Integer createUser= tpTicketMapper.selectById(ticketId).getCreateUser();
|
|
826
|
+ TaUserVerify taUserVerify= taUserVerifyMapper.selectById(createUser);
|
|
827
|
+
|
|
828
|
+ User taUser= userMapper.selectById(taUserVerify.getUserId());
|
|
829
|
+ TpTicketRecordComment tpTicketRecordComment = new TpTicketRecordComment();
|
|
830
|
+ tpTicketRecordComment.setOrgId(orgId);
|
|
831
|
+ tpTicketRecordComment.setTicketId(ticketId);
|
|
832
|
+ tpTicketRecordComment.setTicketRecordId(tpTicketRecord.getId());
|
|
833
|
+ tpTicketRecordComment.setUuid(userElement.getUserId());
|
|
834
|
+ tpTicketRecordComment.setUuid(taUserVerify.getId());
|
|
835
|
+ tpTicketRecordComment.setUserName(taUser.getUserName());
|
|
836
|
+ tpTicketRecordComment.setContent("业主终止工单,原因——无");
|
|
837
|
+ tpTicketRecordComment.setCreateDate(LocalDateTime.now());
|
|
838
|
+ tpTicketRecordCommentMapper.insert(tpTicketRecordComment);
|
|
839
|
+
|
|
840
|
+ TpTicket ticket= tpTicketMapper.selectById(ticketId);
|
|
841
|
+ // 推物业端,推这个小区下的所有管理员
|
|
842
|
+// List<TpUser> tpUserList= tpUserMapper.selectCommunityId(communityId);
|
|
843
|
+// for (TpUser tpUser:tpUserList) {
|
|
844
|
+// Map<String, Object> mapProp = new HashMap<>();
|
|
845
|
+// mapProp.put("communityId", communityId);
|
|
846
|
+// mapProp.put("createUserId", userElement.getUserVerifyId());
|
|
847
|
+// mapProp.put("title", ticket.getTicketTitle());
|
|
848
|
+// mapProp.put("name", userElement.getUserName());
|
|
849
|
+// mapProp.put("ticketId", ticketId);
|
|
850
|
+// mapProp.put("tpUserId", tpUser.getId());
|
|
851
|
+// applicationContext.publishEvent(new MessageEvent(mapProp, Constant.TICKET_TERMINATION, mapProp));
|
|
852
|
+// }
|
|
853
|
+ return responseBean;
|
|
854
|
+ } catch (Exception e) {
|
|
855
|
+ e.printStackTrace();
|
|
856
|
+ responseBean.addError("服务器异常");
|
|
857
|
+ return responseBean;
|
|
858
|
+ }
|
|
859
|
+ }
|
|
860
|
+
|
|
861
|
+ /**
|
|
862
|
+ * 公共方法
|
|
863
|
+ * 把工单插入消息表
|
|
864
|
+ *
|
|
865
|
+ * @param tpTicket 工单
|
|
866
|
+ * @param userId 用户id
|
|
867
|
+ */
|
|
868
|
+ private Message insertTicketMessage(TpTicket tpTicket, Integer userId) {
|
|
869
|
+
|
|
870
|
+ Message tpMessage = new Message();
|
|
871
|
+ tpMessage.setOrgId(tpTicket.getOrgId());
|
|
872
|
+ // 消息类型 1:投诉 2:报修 3:联系物业 4: 访客 5:公告 6:系统通知 7:账单 8:活动
|
|
873
|
+ tpMessage.setMessageType(tpTicket.getType());
|
|
874
|
+ // 通知方式: APP 内通知
|
|
875
|
+ tpMessage.setAdviceType("1");
|
|
876
|
+ // 模板类型为 消息模板
|
|
877
|
+ tpMessage.setModelType("1");
|
|
878
|
+ tpMessage.setUuid(userId);
|
|
879
|
+ // 接收人类型: APP用户
|
|
880
|
+ tpMessage.setUuidType("1");
|
|
881
|
+ // 来源: APP 端用户
|
|
882
|
+ tpMessage.setSource("1");
|
|
883
|
+ // 这里的消息内容对应, 工单标题
|
|
884
|
+ tpMessage.setMessageContent(tpTicket.getTicketTitle());
|
|
885
|
+ tpMessage.setStatus("1");
|
|
886
|
+ // 阅读状态: 0未阅读
|
|
887
|
+ tpMessage.setReadStatus("0");
|
|
888
|
+ tpMessage.setCreateUser(userId);
|
|
889
|
+ tpMessage.setCreateDate(LocalDateTime.now());
|
|
890
|
+ tpMessage.setUpdateUser(userId);
|
|
891
|
+ tpMessage.setUpdateDate(LocalDateTime.now());
|
|
892
|
+
|
|
893
|
+ messageMapper.insert(tpMessage);
|
|
894
|
+
|
|
895
|
+ return tpMessage;
|
|
896
|
+
|
|
897
|
+ }
|
|
898
|
+ @Override
|
|
899
|
+ public ResponseBean addWxRecordComment(String parameter, Integer verifyId,Integer communityId,String userName) {
|
|
900
|
+ ResponseBean response=new ResponseBean();
|
|
901
|
+ JSONObject object= JSONObject.parseObject(parameter);
|
|
902
|
+
|
|
903
|
+ String content = object.getString("content");
|
|
904
|
+ Integer ticketId = object.getInteger("ticketId");
|
|
905
|
+
|
|
906
|
+ /*根据工单Id和状态查出工单记录ID*/
|
|
907
|
+ TpTicket tpTicket= tpTicketMapper.selectById(ticketId);
|
|
908
|
+ TpTicketRecord ticketRecord= tpTicketRecordMapper.selectTpTicketRecord(ticketId, Integer.valueOf(tpTicket.getStatus()));
|
|
909
|
+ TpTicketRecordComment tpTicketRecordComment= new TpTicketRecordComment();
|
|
910
|
+ tpTicketRecordComment.setOrgId(communityId);
|
|
911
|
+ tpTicketRecordComment.setContent(content);
|
|
912
|
+ tpTicketRecordComment.setTicketId(ticketId);
|
|
913
|
+ tpTicketRecordComment.setTicketRecordId(ticketRecord.getId());
|
|
914
|
+ tpTicketRecordComment.setUuid(verifyId);
|
|
915
|
+ tpTicketRecordComment.setUserType("1");
|
|
916
|
+ tpTicketRecordComment.setUserName(userName);
|
|
917
|
+ tpTicketRecordComment.setCreateDate(LocalDateTime.now());
|
|
918
|
+ tpTicketRecordCommentMapper.insert(tpTicketRecordComment);
|
|
919
|
+ JSONArray contentImg = object.getJSONArray("imageUrl");
|
|
920
|
+ if (null!=contentImg){
|
|
921
|
+ String[] contentImgArray = contentImg.toArray(new String[]{});
|
|
922
|
+
|
|
923
|
+ for (String img : contentImgArray) {
|
|
924
|
+ TdImages tdImages = new TdImages();
|
|
925
|
+ tdImages.setImageUrl(img);
|
|
926
|
+ /*注意reply用于标记工单回复类的图片*/
|
|
927
|
+ tdImages.setType("reply");
|
|
928
|
+ tdImages.setUuid(tpTicketRecordComment.getId());
|
|
929
|
+ tdImages.setCreateTime(LocalDateTime.now());
|
|
930
|
+ tdImages.setCreateUser(verifyId);
|
|
931
|
+ tdImagesMapper.insert(tdImages);
|
|
932
|
+ }
|
|
933
|
+ }
|
|
934
|
+ //1.5版本推送消息message
|
|
935
|
+ //工单消息回复最最后一个物业人员
|
|
936
|
+
|
|
937
|
+ Message message = new Message();
|
|
938
|
+ message.setOrgId(communityId);
|
|
939
|
+ message.setModelType("1");
|
|
940
|
+ message.setMessageType(tpTicket.getType());
|
|
941
|
+ message.setAdviceType("4");
|
|
942
|
+ //查询当前工单处理
|
|
943
|
+// TpTicket ticket= tpTicketMapper.getTicketTpUserId(ticketId,communityId);
|
|
944
|
+// //考虑到工单没有分配,物业人员没有追问,只能塞本小区超级管理员ID
|
|
945
|
+// TpTicketRecordComment recordComment= tpTicketRecordCommentMapper.getUuID(communityId,ticketId);
|
|
946
|
+// Integer uuserID= toCommunitiesMapper.selectAndmin(communityId);
|
|
947
|
+// // 查询工单创建人名称
|
|
948
|
+// TaUserVerify taUserVerify = taUserVerifyMapper.selectByPrimaryKey(ticket.getCreateUser());
|
|
949
|
+// TaUser taUser = taUserMapper.selectByPrimaryKey(taUserVerify.getUserId());
|
|
950
|
+ // app推送物业端的消息
|
|
951
|
+// Map<String,Object> mapPorp = new HashMap<>();
|
|
952
|
+// mapPorp.put("communityId",communityId);
|
|
953
|
+// mapPorp.put("createUserId",tpTicket.getCreateUser());
|
|
954
|
+// mapPorp.put("uuId",recordComment==null?uuserID:recordComment.getUuid());
|
|
955
|
+// mapPorp.put("ticketId",ticketId);
|
|
956
|
+// mapPorp.put("replyCount","业主"+taUser.getUserName()+"回复了工单“"+ticket.getTicketTitle()+"”,请处理");
|
|
957
|
+// mapPorp.put("uuidType",Constant.UUID_TYPE_PROP);
|
|
958
|
+// mapPorp.put("source",Constant.SOURCE_APP);
|
|
959
|
+// applicationContext.publishEvent(new MessageEvent(tpTicket, Constant.TICKET_REPLY_PROP,mapPorp));
|
|
960
|
+ response.addSuccess("成功");
|
|
961
|
+ return response;
|
|
962
|
+ }
|
429
|
963
|
}
|