|
|
@@ -1,6 +1,7 @@
|
|
|
package com.repair.controller;
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.jcraft.jsch.*;
|
|
|
@@ -65,6 +66,8 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
@Autowired
|
|
|
private RepairDispatchRecordService repairDispatchRecordService;
|
|
|
@Autowired
|
|
|
+ private RepairSystemMessagesService repairSystemMessagesService;
|
|
|
+ @Autowired
|
|
|
private RepairCollaborateRecordService repairCollaborateRecordService;
|
|
|
@Autowired
|
|
|
private RepairArticleTypeService repairArticleTypeService;
|
|
|
@@ -74,7 +77,10 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
private RepairConsumeService repairConsumeService;
|
|
|
@Autowired
|
|
|
private RepairAdminService repairAdminService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private RepairEvaluateService repairEvaluateService;
|
|
|
+ @Autowired
|
|
|
+ private RepairSchoolService repairSchoolService;
|
|
|
@Autowired
|
|
|
private WeiXiaoUtil weiXiaoUtil;
|
|
|
|
|
|
@@ -101,6 +107,7 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
rr.setDescription(rrr.getDescription());
|
|
|
rr.setImage(StringUtils.join(rrr.getImages(), ','));
|
|
|
rr.setVoice(rrr.getVoice());
|
|
|
+ rr.setVoiceLength(rrr.getVoiceLength());
|
|
|
rr.setUserId(rrr.getUserId());
|
|
|
rr.setUserName(rrr.getUserName());
|
|
|
rr.setUserPhone(rrr.getUserPhone());
|
|
|
@@ -183,6 +190,7 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
rdr.setAcceptanceAssessTime(acceptanceAssessTime);
|
|
|
rdr.setOrderType(0);
|
|
|
rdr.setIsLoseEfficacy(0);
|
|
|
+ rdr.setUsersId(user.getId());
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
@@ -198,15 +206,48 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
throw new Exception("报修单提交失败!");
|
|
|
}
|
|
|
|
|
|
+ //两种情况:
|
|
|
+ //1、工单已提交(没找到被派单师傅)
|
|
|
+ //工单已生成,将尽快为您派单。
|
|
|
+ //2、工单待接单(找到了被派单)
|
|
|
+ //工单已交给系统,系统将催促师傅师尽快接单。
|
|
|
if (rdr != null) {
|
|
|
rdr.setRecordId(result);
|
|
|
- rdr.setUsersId(rrr.getUserId());
|
|
|
+
|
|
|
int dispatch = repairDispatchRecordService.insertRepairDispatchRecord(rdr);
|
|
|
if (dispatch <= 0) {
|
|
|
throw new Exception("报修单提交失败!");
|
|
|
}
|
|
|
+ List<RepairSystemMessages> rsms = new ArrayList<>();
|
|
|
+ RepairSystemMessages rsm = new RepairSystemMessages();
|
|
|
+ rsm.setIsRead(0);
|
|
|
+ rsm.setRecordId(result);
|
|
|
+ rsm.setRecipientId(rdr.getUsersId());
|
|
|
+ rsm.setContent("用户提交工单,请尽快处理!");
|
|
|
+ rsms.add(rsm);
|
|
|
+ RepairSystemMessages rsm1 = new RepairSystemMessages();
|
|
|
+ rsm1.setIsRead(0);
|
|
|
+ rsm1.setRecordId(result);
|
|
|
+ rsm1.setRecipientId(rrr.getUserId());
|
|
|
+ rsm1.setContent("工单已交给系统,系统将催促师傅师尽快接单!");
|
|
|
+ rsms.add(rsm1);
|
|
|
+ boolean insertRsm = repairSystemMessagesService.inserBatchSystemMessage(rsms);
|
|
|
+ if (!insertRsm) {
|
|
|
+ throw new Exception("报修单提交失败!");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ RepairSystemMessages rsm = new RepairSystemMessages();
|
|
|
+ rsm.setIsRead(0);
|
|
|
+ rsm.setRecordId(result);
|
|
|
+ rsm.setRecipientId(rrr.getUserId());
|
|
|
+ rsm.setContent("工单已生成,将尽快为您派单!");
|
|
|
+ int insertRsm = repairSystemMessagesService.insertRepairSystemMessages(rsm);
|
|
|
+ if (insertRsm <= 0) {
|
|
|
+ throw new Exception("报修单提交失败!");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
throw new Exception("报修单提交失败!");
|
|
|
}
|
|
|
@@ -304,19 +345,65 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public CommonResult revokeRepairRecordById(int id) {
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
+ public CommonResult revokeRepairRecordById(int id) throws Exception {
|
|
|
RepairRecord data = repairRecordService.getRepairById(id);
|
|
|
if (data == null) {
|
|
|
return CommonResult.fail("当前数据不存在,撤销失败!");
|
|
|
}
|
|
|
|
|
|
- RepairRecord rr = new RepairRecord();
|
|
|
- rr.setId(id);
|
|
|
- rr.setMaintenanceState(eRecordStatu.Canceled.getValue());
|
|
|
+ if (data.getMaintenanceState() != eRecordStatu.Dispatch.getValue() || data.getMaintenanceState() != eRecordStatu.ToConfirmed.getValue()) {
|
|
|
+ return CommonResult.fail("待接单或待确认才能进行撤销操作!");
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ List<Integer> userIds = new ArrayList<>();
|
|
|
+ //获取该维修单的派单记录数据
|
|
|
+ List<RepairDispatchRecord> rdrs = repairDispatchRecordService.queryDispatchByRecordId(data.getId());
|
|
|
+ if (rdrs.size() > 0) {
|
|
|
+ userIds = rdrs.stream().map(RepairDispatchRecord::getUsersId).collect(Collectors.toList());
|
|
|
+ //将该维修单的派单记录和接单记录都置为无效
|
|
|
+ RepairDispatchRecord rdr = new RepairDispatchRecord();
|
|
|
+ int updateD = repairDispatchRecordService.updateDispatch(data.getId(), rdr.setIsLoseEfficacy(eDispatchResult.Expired.getValue()));
|
|
|
+ if (updateD <= 0) {
|
|
|
+ throw new Exception("撤销失败!");
|
|
|
+ }
|
|
|
+ if (rdrs.get(0).getReceivingTime() != null) {
|
|
|
+ RepairReceiving rr = new RepairReceiving();
|
|
|
+ int updateR = repairReceivingService.updateReceiving(data.getId(), rr.setIsLoseEfficacy(eDispatchResult.Expired.getValue()));
|
|
|
+ if (updateR <= 0) {
|
|
|
+ throw new Exception("撤销失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (userIds.size() > 0) {
|
|
|
+ List<RepairSystemMessages> rsms = new ArrayList<>();
|
|
|
+ for (int i = 0; i < userIds.size(); i++) {
|
|
|
+ RepairSystemMessages rsm = new RepairSystemMessages();
|
|
|
+ rsm.setIsRead(0);
|
|
|
+ rsm.setRecordId(data.getId());
|
|
|
+ rsm.setRecipientId(userIds.get(i));
|
|
|
+ rsm.setContent("工单已被用户取消!");
|
|
|
+ rsms.add(rsm);
|
|
|
+ }
|
|
|
+ boolean insertRsm = repairSystemMessagesService.inserBatchSystemMessage(rsms);
|
|
|
+ if (!insertRsm) {
|
|
|
+ throw new Exception("撤销失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ data.setMaintenanceState(eRecordStatu.Canceled.getValue());
|
|
|
+ int result = repairRecordService.updateRepairRecord(data);
|
|
|
+ if (result <= 0) {
|
|
|
+ throw new Exception("撤销失败!");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new Exception("撤销失败!");
|
|
|
+ }
|
|
|
|
|
|
- int result = repairRecordService.updateRepairRecord(rr);
|
|
|
|
|
|
- return result > 0 ? CommonResult.ok("撤销成功") : CommonResult.fail("撤销失败");
|
|
|
+ return CommonResult.ok("撤销成功");
|
|
|
}
|
|
|
|
|
|
@Override//还要处理一下订单超时状态
|
|
|
@@ -386,22 +473,41 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
}
|
|
|
|
|
|
List<String> cardnumber = new ArrayList<>();
|
|
|
+ List<Integer> userIds = new ArrayList<>();
|
|
|
|
|
|
// 有的话就发给被派单的维修师傅
|
|
|
// 否则就发给郭师傅
|
|
|
List<RepairCardNumberVo> cardNumbers = repairDispatchRecordService.queryRepairCardNumber(recordId);
|
|
|
if (cardNumbers.size() <= 0) {
|
|
|
+ //获取郭师傅的卡号把消息发给郭师傅
|
|
|
List<Integer> uz = new ArrayList<>();
|
|
|
uz.add(eUserZZ.Monitor.getValue());
|
|
|
List<RepairUser> users = repairUserService.getRepairByUserZZ(uz, record.getSchoolId());
|
|
|
cardnumber = users.stream().map(RepairUser::getCardNumber).collect(Collectors.toList());
|
|
|
+ userIds = users.stream().map(RepairUser::getId).collect(Collectors.toList());
|
|
|
} else {
|
|
|
cardnumber = cardNumbers.stream().map(RepairCardNumberVo::getCardNumber).collect(Collectors.toList());
|
|
|
+ userIds = cardNumbers.stream().map(RepairCardNumberVo::getUserId).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
if (cardnumber.size() <= 0) {
|
|
|
return CommonResult.fail("当前工单无接收人,催单失败");
|
|
|
}
|
|
|
+
|
|
|
+ List<RepairSystemMessages> rsms = new ArrayList<>();
|
|
|
+ for (int i = 0; i < userIds.size(); i++) {
|
|
|
+ RepairSystemMessages rsm = new RepairSystemMessages();
|
|
|
+ rsm.setIsRead(0);
|
|
|
+ rsm.setRecordId(recordId);
|
|
|
+ rsm.setRecipientId(userIds.get(i));
|
|
|
+ rsm.setContent("您有工单用户催促,请尽快处理!");
|
|
|
+ rsms.add(rsm);
|
|
|
+ }
|
|
|
+ boolean insertS = repairSystemMessagesService.inserBatchSystemMessage(rsms);
|
|
|
+ if (!insertS) {
|
|
|
+ return CommonResult.fail("催单失败");
|
|
|
+ }
|
|
|
+
|
|
|
String content = MessageFormat.format("【报修系统】维修师傅,你好,工单{0}用户催单,请及时处理,谢谢!", record.getRecordNo());
|
|
|
CommonResult result = weiXiaoUtil.sendNotice(cardnumber, "报修工单催单", "催单", content, null);
|
|
|
return result;
|
|
|
@@ -607,8 +713,8 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public CommonResult queryPendingOrder(int currentPage, int pageCount, int userId) {
|
|
|
- PageUtils<pendingOrderVo> result = repairRecordService.queryPendingOrder(currentPage, pageCount, userId);
|
|
|
+ public CommonResult queryPendingOrder(int currentPage, int pageCount) {
|
|
|
+ PageUtils<pendingOrderVo> result = repairRecordService.queryPendingOrder(currentPage, pageCount);
|
|
|
return CommonResult.ok(result);
|
|
|
}
|
|
|
|
|
|
@@ -759,12 +865,22 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
throw new Exception("抢单失败!");
|
|
|
}
|
|
|
|
|
|
+ //给用户发消息
|
|
|
+ RepairSystemMessages rsm = new RepairSystemMessages();
|
|
|
+ rsm.setIsRead(0);
|
|
|
+ rsm.setRecordId(recordId);
|
|
|
+ rsm.setRecipientId(recordData.getUserId());
|
|
|
+ rsm.setContent("工单已被" + recordData.getMaintenancerName() + "接单,电话" + recordData.getMaintenancerPhone() + ",师傅会尽快上门维修。");
|
|
|
+ int insertRsm = repairSystemMessagesService.insertRepairSystemMessages(rsm);
|
|
|
+ if (insertRsm <= 0) {
|
|
|
+ throw new Exception("抢单失败!");
|
|
|
+ }
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
- //return CommonResult.fail("抢单失败");
|
|
|
throw new Exception("抢单失败!");
|
|
|
}
|
|
|
|
|
|
- return CommonResult.ok("抢单成功");
|
|
|
+ return CommonResult.ok("工单已被您接单,请和用户确认上门维修时间");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -873,7 +989,7 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
|
|
|
//将工单状态更新为维修中
|
|
|
recordData.setMaintenanceState(eRecordStatu.Maintenance.getValue());
|
|
|
- String mi = dispatch.getOrderType() == eDispatchType.Cooperation.getValue() ? recordData.getMaintenancerId() + "," + String.valueOf(userId) : String.valueOf(userId);
|
|
|
+ String mi = dispatch.getOrderType() == eDispatchType.Cooperation.getValue() ? recordData.getMaintenancerId() == null ? String.valueOf(userId) : recordData.getMaintenancerId() + "," + String.valueOf(userId) : String.valueOf(userId);
|
|
|
recordData.setMaintenancerId(mi);
|
|
|
recordData.setMaintenancerName(result.getUserName());
|
|
|
recordData.setMaintenancerPhone(result.getUserPhone());
|
|
|
@@ -903,10 +1019,21 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
throw new Exception("接单失败!");
|
|
|
}
|
|
|
|
|
|
+ RepairSystemMessages rsm = new RepairSystemMessages();
|
|
|
+ rsm.setIsRead(0);
|
|
|
+ rsm.setRecordId(recordId);
|
|
|
+ rsm.setRecipientId(userId);
|
|
|
+ rsm.setContent("工单已被" + result.getUserName() + "接单,电话" + result.getUserPhone() + ",师傅会尽快上门维修。");
|
|
|
+ int insertRsm = repairSystemMessagesService.insertRepairSystemMessages(rsm);
|
|
|
+ if (insertRsm <= 0) {
|
|
|
+ throw new Exception("报修单提交失败!");
|
|
|
+ }
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
throw new Exception("接单失败!");
|
|
|
}
|
|
|
- return CommonResult.ok("接单成功");
|
|
|
+
|
|
|
+ return CommonResult.ok("工单已被您接单,请和用户确认上门维修时间");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1025,6 +1152,7 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
RepairTrackRecord repairTrackRecord = new RepairTrackRecord();
|
|
|
repairTrackRecord.setRecordId(rsor.getRecordId());
|
|
|
repairTrackRecord.setContent("派单");
|
|
|
+ repairTrackRecord.setMaintenanceState(rr.getMaintenanceState());
|
|
|
int insertTrack = repairTrackRecordService.insertRepairTrackRecord(repairTrackRecord);
|
|
|
if (insertTrack <= 0) {
|
|
|
throw new Exception("派单失败!");
|
|
|
@@ -1044,15 +1172,28 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@Override
|
|
|
- public CommonResult dropDown() throws Exception {
|
|
|
-// 将可以接单的师傅显示到协作下拉框中(员工状态 大量接单:1)
|
|
|
- LambdaQueryWrapper<RepairUser> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(RepairUser::getState, eUserStatu.Received.getValue())
|
|
|
- .eq(RepairUser::getUserZzid, eUserZZ.Maintenance.getValue());
|
|
|
+ public CommonResult dropDown(Integer recordId) throws Exception {
|
|
|
+
|
|
|
+ RepairRecord rr = repairRecordService.getRepairById(recordId);
|
|
|
+
|
|
|
+ if (rr == null) {
|
|
|
+ return CommonResult.fail("维修单无效,获取维修师傅数据失败");
|
|
|
+ }
|
|
|
|
|
|
- List<RepairUser> repairUsers = repairUserService.list(wrapper);
|
|
|
+ Integer buildId = rr.getBuildId();
|
|
|
+ Integer articleId = rr.getArticleId();
|
|
|
+ Integer schoolId = rr.getSchoolId();
|
|
|
|
|
|
- return CommonResult.ok(repairUsers);
|
|
|
+ List<AutoDispatchUserVo> autoDispatchUserVos = repairUserService.dropDown(buildId, articleId, schoolId);
|
|
|
+
|
|
|
+//// 将可以接单的师傅显示到协作下拉框中(员工状态 大量接单:1)
|
|
|
+// LambdaQueryWrapper<RepairUser> wrapper = new LambdaQueryWrapper<>();
|
|
|
+// wrapper.eq(RepairUser::getState, eUserStatu.Received.getValue())
|
|
|
+// .like(RepairUser::getArticle_id,articleId);
|
|
|
+//
|
|
|
+// List<RepairUser> repairUsers = repairUserService.list(wrapper);
|
|
|
+
|
|
|
+ return CommonResult.ok(autoDispatchUserVos);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1071,6 +1212,10 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
return CommonResult.fail(st);
|
|
|
}
|
|
|
|
|
|
+ if (eApprovalStatu.Agree.getValue() == tr.getApproverStatu() && tr.getUserId() == null) {
|
|
|
+ return CommonResult.fail("被派单师傅不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
//获取转单审核数据
|
|
|
RepairTransferRecord transferRecord = repairTransferRecordService.getById(tr.getId());
|
|
|
if (transferRecord == null) {
|
|
|
@@ -1086,12 +1231,6 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
return CommonResult.fail("维修单状态异常,审核失败");
|
|
|
}
|
|
|
|
|
|
- //被派单用户
|
|
|
- RepairUser repairUser = repairUserService.getById(tr.getUserId());
|
|
|
- if (repairUser == null) {
|
|
|
- return CommonResult.fail("被派单师傅数据异常,审核失败");
|
|
|
- }
|
|
|
-
|
|
|
String userID = AesUtils.decrypt(userhead);
|
|
|
RepairAdmin operateData = repairAdminService.getRepairById(userID);
|
|
|
if (operateData == null) {
|
|
|
@@ -1118,6 +1257,12 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
}
|
|
|
|
|
|
if (eApprovalStatu.Agree.getValue() == tr.getApproverStatu()) {
|
|
|
+ //被派单用户
|
|
|
+ RepairUser repairUser = repairUserService.getById(tr.getUserId());
|
|
|
+ if (repairUser == null) {
|
|
|
+ return CommonResult.fail("被派单师傅数据异常,审核失败");
|
|
|
+ }
|
|
|
+
|
|
|
//同意
|
|
|
//添加派单记录
|
|
|
RepairDispatchRecord repairDispatchRecord = new RepairDispatchRecord();
|
|
|
@@ -1145,10 +1290,22 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
RepairTrackRecord repairTrackRecord = new RepairTrackRecord();
|
|
|
repairTrackRecord.setRecordId(rr.getId());
|
|
|
repairTrackRecord.setContent("转单审核");
|
|
|
+ repairTrackRecord.setMaintenanceState(rr.getMaintenanceState());
|
|
|
int insertTrack = repairTrackRecordService.insertRepairTrackRecord(repairTrackRecord);
|
|
|
if (insertTrack <= 0) {
|
|
|
throw new Exception("转单审核失败!");
|
|
|
}
|
|
|
+
|
|
|
+ RepairSystemMessages rsm = new RepairSystemMessages();
|
|
|
+ rsm.setIsRead(0);
|
|
|
+ rsm.setRecordId(transferRecord.getRecordId());
|
|
|
+ rsm.setRecipientId(transferRecord.getApproverId());
|
|
|
+ rsm.setContent(eApprovalStatu.Agree.getValue() == tr.getApproverStatu() ? "您的审核工单已通过!" : "您的审核工单被驳回");
|
|
|
+ int insertRsm = repairSystemMessagesService.insertRepairSystemMessages(rsm);
|
|
|
+ if (insertRsm <= 0) {
|
|
|
+ throw new Exception("协作审核失败!");
|
|
|
+ }
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
throw new Exception("转单审核失败!");
|
|
|
}
|
|
|
@@ -1301,10 +1458,22 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
RepairTrackRecord repairTrackRecord = new RepairTrackRecord();
|
|
|
repairTrackRecord.setRecordId(rr.getId());
|
|
|
repairTrackRecord.setContent("协作审核");
|
|
|
+ repairTrackRecord.setMaintenanceState(rr.getMaintenanceState());
|
|
|
int insertTrack = repairTrackRecordService.insertRepairTrackRecord(repairTrackRecord);
|
|
|
if (insertTrack <= 0) {
|
|
|
throw new Exception("协作审核失败!");
|
|
|
}
|
|
|
+
|
|
|
+ RepairSystemMessages rsm = new RepairSystemMessages();
|
|
|
+ rsm.setIsRead(0);
|
|
|
+ rsm.setRecordId(collaborateRecord.getRecordId());
|
|
|
+ rsm.setRecipientId(collaborateRecord.getApproverId());
|
|
|
+ rsm.setContent(eApprovalStatu.Agree.getValue() == cor.getApproverStatu() ? "您的审核工单已通过!" : "您的审核工单被驳回");
|
|
|
+ int insertRsm = repairSystemMessagesService.insertRepairSystemMessages(rsm);
|
|
|
+ if (insertRsm <= 0) {
|
|
|
+ throw new Exception("协作审核失败!");
|
|
|
+ }
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
throw new Exception("协作审核失败!");
|
|
|
}
|
|
|
@@ -1746,15 +1915,17 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
// 状态为0是查全部,为1查派单中。为2查维修中,3查转后勤,4是查转单待审核,协作待审核,5是查已完成,6是查已取消,7是查已关单,8是查维修中值班单
|
|
|
|
|
|
|
|
|
- String userID = AesUtils.decrypt(userhead);
|
|
|
- RepairAdmin operateData = repairAdminService.getRepairById(userID);
|
|
|
- if (operateData == null) {
|
|
|
-// return CommonResult.fail("操作人信息不合法,无法获取工单数据!");
|
|
|
- return;
|
|
|
- }
|
|
|
- if (operateData.getIsSuper().equals(eIsSuper.Super.getValue())) {
|
|
|
- schoolId = null;
|
|
|
- }
|
|
|
+// String userID = AesUtils.decrypt(userhead);
|
|
|
+// RepairAdmin operateData = repairAdminService.getRepairById(userID);
|
|
|
+// if (operateData == null) {
|
|
|
+//// return CommonResult.fail("操作人信息不合法,无法获取工单数据!");
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (operateData.getIsSuper().equals(eIsSuper.Super.getValue())) {
|
|
|
+// schoolId = null;
|
|
|
+// }
|
|
|
+
|
|
|
|
|
|
List<ReportExportVo> result = null;
|
|
|
|
|
|
@@ -1899,6 +2070,302 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
return CommonResult.ok(result);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 报修校区统计
|
|
|
+ *
|
|
|
+ * @param state
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public CommonResult repairCampus(int state) throws Exception {
|
|
|
+
|
|
|
+
|
|
|
+// 全部
|
|
|
+ if (state == 0) {
|
|
|
+ List<RepairCampusVo> campusVoList = repairRecordService.repairCampusTotal();
|
|
|
+ return CommonResult.ok(campusVoList);
|
|
|
+ }
|
|
|
+
|
|
|
+ String startTime = DateUtils.startTime(state);
|
|
|
+ String endTime = DateUtils.endTime();
|
|
|
+
|
|
|
+ if (ObjectUtils.isEmpty(startTime)) {
|
|
|
+ return CommonResult.fail("参数有误");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<RepairCampusVo> campusVoList = repairRecordService.repairCampus(startTime, endTime);
|
|
|
+
|
|
|
+
|
|
|
+ return CommonResult.ok(campusVoList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 报修区域
|
|
|
+ *
|
|
|
+ * @param state
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public CommonResult repairArea(int state) throws Exception {
|
|
|
+ // 全部
|
|
|
+ if (state == 0) {
|
|
|
+ List<RepairAreaVo> repairAreaTotal = repairRecordService.repairAreaTotal();
|
|
|
+ return CommonResult.ok(repairAreaTotal);
|
|
|
+ }
|
|
|
+
|
|
|
+ String startTime = DateUtils.startTime(state);
|
|
|
+ String endTime = DateUtils.endTime();
|
|
|
+
|
|
|
+ if (ObjectUtils.isEmpty(startTime)) {
|
|
|
+ return CommonResult.fail("参数有误");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<RepairAreaVo> repairAreaTotal = repairRecordService.repairArea(startTime, endTime);
|
|
|
+
|
|
|
+ return CommonResult.ok(repairAreaTotal);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 维修物品
|
|
|
+ *
|
|
|
+ * @param state
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public CommonResult maintenanceGoods(int state) throws Exception {
|
|
|
+ // 全部
|
|
|
+ if (state == 0) {
|
|
|
+ List<MaintenanceGoodsVo> maintenanceGoodsVoList = repairRecordService.maintenanceGoodsTotal();
|
|
|
+ return CommonResult.ok(maintenanceGoodsVoList);
|
|
|
+ }
|
|
|
+
|
|
|
+ String startTime = DateUtils.startTime(state);
|
|
|
+ String endTime = DateUtils.endTime();
|
|
|
+
|
|
|
+ if (ObjectUtils.isEmpty(startTime)) {
|
|
|
+ return CommonResult.fail("参数有误");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<MaintenanceGoodsVo> maintenanceGoodsVoList = repairRecordService.maintenanceGoods(startTime, endTime);
|
|
|
+ return CommonResult.ok(maintenanceGoodsVoList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 维修师傅
|
|
|
+ *
|
|
|
+ * @param state
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public CommonResult maintenanceWorker(int state) throws Exception {
|
|
|
+
|
|
|
+ String startTime = DateUtils.startTime(state);
|
|
|
+ String endTime = DateUtils.endTime();
|
|
|
+
|
|
|
+ LambdaQueryWrapper<RepairReceiving> wrapperReceiving = new LambdaQueryWrapper<>();
|
|
|
+ wrapperReceiving.between(ObjectUtils.isNotEmpty(startTime), RepairReceiving::getReceivingTime, startTime, endTime);
|
|
|
+ wrapperReceiving.isNotNull(RepairReceiving::getFinishTime);
|
|
|
+ List<RepairReceiving> repairReceivingList = repairReceivingService.list(wrapperReceiving);
|
|
|
+
|
|
|
+ ArrayList<Integer> userList = new ArrayList<>();
|
|
|
+
|
|
|
+// ArrayList<Integer> recordList = new ArrayList<>();
|
|
|
+
|
|
|
+// 接单总次数
|
|
|
+ HashMap<Integer, List<Integer>> receivingCountMap = new HashMap<>();
|
|
|
+
|
|
|
+// 维修超时次数
|
|
|
+ Map<Integer, Integer> maintainTimeOutMap = new HashMap<>();
|
|
|
+
|
|
|
+// 维修总时长
|
|
|
+ Map<Integer, Long> maintainMap = new HashMap<>();
|
|
|
+
|
|
|
+
|
|
|
+ for (RepairReceiving repairReceiving : repairReceivingList) {
|
|
|
+ Date finishTime = repairReceiving.getFinishTime();
|
|
|
+
|
|
|
+ if (ObjectUtils.isEmpty(finishTime)) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer userId = repairReceiving.getUserId();
|
|
|
+ userList.add(userId);
|
|
|
+
|
|
|
+ Integer recordId = repairReceiving.getRecordId();
|
|
|
+// recordList.add(recordId);
|
|
|
+
|
|
|
+ if (receivingCountMap.containsKey(userId)) {
|
|
|
+// 总次数
|
|
|
+ List<Integer> list = receivingCountMap.get(userId);
|
|
|
+ list.add(recordId);
|
|
|
+ receivingCountMap.put(userId, list);
|
|
|
+ } else {
|
|
|
+ ArrayList<Integer> list = new ArrayList<>();
|
|
|
+ list.add(recordId);
|
|
|
+ receivingCountMap.put(userId, list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+// 接单时间
|
|
|
+ long receivingTime = repairReceiving.getReceivingTime().getTime();
|
|
|
+// 考核时间(分)
|
|
|
+ Integer maintenanceAssessTime = repairReceiving.getMaintenanceAssessTime() * 1000 * 60;
|
|
|
+
|
|
|
+ long time = receivingTime + maintenanceAssessTime;
|
|
|
+
|
|
|
+// 完成时间
|
|
|
+ long finishTimeTime = finishTime.getTime();
|
|
|
+
|
|
|
+// 实际完成时间大于接单时间加考核时间为超时
|
|
|
+ if (finishTimeTime > time) {
|
|
|
+ if (maintainTimeOutMap.containsKey(userId)) {
|
|
|
+// 次数
|
|
|
+ Integer count = maintainTimeOutMap.get(userId);
|
|
|
+ count = count + 1;
|
|
|
+ maintainTimeOutMap.put(userId, count);
|
|
|
+ } else {
|
|
|
+ maintainTimeOutMap.put(userId, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+// 维修时长=完成时间-接单时间(分)
|
|
|
+ long maintainTime = finishTimeTime - receivingTime;
|
|
|
+ maintainTime=maintainTime/1000/60;
|
|
|
+
|
|
|
+ if (maintainMap.containsKey(userId)) {
|
|
|
+// 维修时长
|
|
|
+ Long maintainTotalTime = maintainMap.get(userId);
|
|
|
+ maintainTotalTime = maintainTotalTime + maintainTime;
|
|
|
+ maintainMap.put(userId, maintainTotalTime);
|
|
|
+ } else {
|
|
|
+ maintainMap.put(userId, maintainTime);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaQueryWrapper<RepairUser> userWrapper=new LambdaQueryWrapper<>();
|
|
|
+ userWrapper.in(RepairUser::getId,userList);
|
|
|
+
|
|
|
+ List<RepairUser> users = repairUserService.list(userWrapper);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Wrapper<RepairSchool> schoolWrapper=new LambdaQueryWrapper<>();
|
|
|
+ List<RepairSchool> schoolList = repairSchoolService.list(schoolWrapper);
|
|
|
+
|
|
|
+ users.forEach(repairUser -> {
|
|
|
+ MaintenanceWorkerVo maintenanceWorkerVo = new MaintenanceWorkerVo();
|
|
|
+// 名字
|
|
|
+ maintenanceWorkerVo.setName(repairUser.getUserName());
|
|
|
+
|
|
|
+// 学校
|
|
|
+ Integer schoolId = repairUser.getSchoolId();
|
|
|
+ for (RepairSchool repairSchool : schoolList) {
|
|
|
+ Integer id = repairSchool.getId();
|
|
|
+ if (id.equals(schoolId)) {
|
|
|
+ maintenanceWorkerVo.setName(repairSchool.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer id = repairUser.getId();
|
|
|
+// 工单集合
|
|
|
+ List<Integer> recordsList = receivingCountMap.get(id);
|
|
|
+ int size = recordsList.size();
|
|
|
+ BigDecimal b = new BigDecimal(size);
|
|
|
+
|
|
|
+// 工单总数
|
|
|
+ maintenanceWorkerVo.setWorkOrderTotal(size);
|
|
|
+
|
|
|
+// 超时率
|
|
|
+ if (maintainTimeOutMap.containsKey(id)) {
|
|
|
+ Integer integer = maintainTimeOutMap.get(id);
|
|
|
+ BigDecimal a = new BigDecimal(integer);
|
|
|
+ BigDecimal bigDecimal = a.divide(b).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal multiply = bigDecimal.multiply(new BigDecimal(100));
|
|
|
+ maintenanceWorkerVo.setTimeOut(multiply+"%");
|
|
|
+ }
|
|
|
+
|
|
|
+// 平均维修时间
|
|
|
+ Long aLong = maintainMap.get(id);
|
|
|
+ BigDecimal bigDecimal = new BigDecimal(aLong);
|
|
|
+ BigDecimal maintain = bigDecimal.divide(b).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ maintenanceWorkerVo.setMaintain(maintain);
|
|
|
+
|
|
|
+// 总费用
|
|
|
+ LambdaQueryWrapper<RepairRecord> recordWrapper=new LambdaQueryWrapper<>();
|
|
|
+ recordWrapper.in(RepairRecord::getId,recordsList);
|
|
|
+
|
|
|
+ List<RepairRecord> list = repairRecordService.list(recordWrapper);
|
|
|
+ BigDecimal totalPrice=new BigDecimal(0);
|
|
|
+ for (RepairRecord repairRecord : list) {
|
|
|
+ BigDecimal price = repairRecord.getPrice();
|
|
|
+ totalPrice=totalPrice.add(price);
|
|
|
+ }
|
|
|
+ maintenanceWorkerVo.setTotalPrice(totalPrice);
|
|
|
+
|
|
|
+// 好评率
|
|
|
+ LambdaQueryWrapper<RepairEvaluate> evaluateWrapper=new LambdaQueryWrapper<>();
|
|
|
+ evaluateWrapper.in(RepairEvaluate::getRecordId,recordsList);
|
|
|
+// 根据工单id来查询对应的评价
|
|
|
+ List<RepairEvaluate> repairEvaluates = repairEvaluateService.list(evaluateWrapper);
|
|
|
+ BigDecimal evaluatesDecimal = new BigDecimal(repairEvaluates.size());
|
|
|
+ BigDecimal satisfaction=new BigDecimal(0);
|
|
|
+ for (RepairEvaluate repairEvaluate : repairEvaluates) {
|
|
|
+ Integer star = repairEvaluate.getStar();
|
|
|
+ if (star>3) {
|
|
|
+ satisfaction=satisfaction.add(new BigDecimal(1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BigDecimal degreePraise = satisfaction.divide(evaluatesDecimal,2).setScale(2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
|
|
+ maintenanceWorkerVo.setDegreePraise(degreePraise+"%");
|
|
|
+
|
|
|
+// 平均响应时长
|
|
|
+ LambdaQueryWrapper<RepairDispatchRecord> rdrsWrapper=new LambdaQueryWrapper<>();
|
|
|
+ rdrsWrapper.in(RepairDispatchRecord::getRecordId,recordsList);
|
|
|
+
|
|
|
+ List<RepairDispatchRecord> repairDispatchRecords = repairDispatchRecordService.list(rdrsWrapper);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 报修分析
|
|
|
+ *
|
|
|
+ * @param state
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public CommonResult repairAnalysis(int state) throws Exception {
|
|
|
+ String startTime = DateUtils.startTime(state);
|
|
|
+ String endTime = DateUtils.endTime();
|
|
|
+
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public CommonResult mobileReply(MobileRevertRequest mrr, BindingResult bindingResult) throws Exception {
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
@@ -1948,6 +2415,17 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
if (!save) {
|
|
|
throw new Exception("回复失败!");
|
|
|
}
|
|
|
+
|
|
|
+ RepairSystemMessages rsm = new RepairSystemMessages();
|
|
|
+ rsm.setIsRead(0);
|
|
|
+ rsm.setRecordId(mrr.getRecordId());
|
|
|
+ rsm.setRecipientId(recipientId);
|
|
|
+ rsm.setContent("用户已回复,请尽快处理!");
|
|
|
+ int insertRsm = repairSystemMessagesService.insertRepairSystemMessages(rsm);
|
|
|
+ if (insertRsm <= 0) {
|
|
|
+ throw new Exception("回复失败!");
|
|
|
+ }
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
throw new Exception("回复失败!");
|
|
|
}
|
|
|
@@ -1956,7 +2434,8 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public CommonResult closeOrders(int recordId, String userId, String reason) {
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
+ public CommonResult closeOrders(int recordId, String userId, String reason) throws Exception {
|
|
|
|
|
|
//获取订单
|
|
|
RepairRecord recordData = repairRecordService.getRepairById(recordId);
|
|
|
@@ -1969,13 +2448,27 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
return CommonResult.fail("待接单状态的工单才能关闭");
|
|
|
}
|
|
|
|
|
|
- //将工单状态更新为维修中
|
|
|
- recordData.setCustomsOfficerId(userId);
|
|
|
- recordData.setRemark(reason);
|
|
|
- recordData.setMaintenanceState(eRecordStatu.Closed.getValue());
|
|
|
- int updateRecord = repairRecordService.updateRepairRecord(recordData);
|
|
|
- if (updateRecord <= 0) {
|
|
|
- return CommonResult.fail("关单失败!");
|
|
|
+ try {
|
|
|
+ //将工单状态更新为维修中
|
|
|
+ recordData.setCustomsOfficerId(userId);
|
|
|
+ recordData.setRemark(reason);
|
|
|
+ recordData.setMaintenanceState(eRecordStatu.Closed.getValue());
|
|
|
+ int updateRecord = repairRecordService.updateRepairRecord(recordData);
|
|
|
+ if (updateRecord <= 0) {
|
|
|
+ return CommonResult.fail("关单失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ RepairSystemMessages rsm = new RepairSystemMessages();
|
|
|
+ rsm.setIsRead(0);
|
|
|
+ rsm.setRecordId(recordId);
|
|
|
+ rsm.setRecipientId(recordData.getUserId());
|
|
|
+ rsm.setContent("工单已被师傅关闭,关单原因为:" + reason + "!");
|
|
|
+ int insertRsm = repairSystemMessagesService.insertRepairSystemMessages(rsm);
|
|
|
+ if (insertRsm <= 0) {
|
|
|
+ throw new Exception("关单失败!");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new Exception("关单失败!");
|
|
|
}
|
|
|
|
|
|
return CommonResult.ok("关单成功");
|
|
|
@@ -2041,6 +2534,7 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
|
|
|
//将工单状态更新为已完成
|
|
|
recordData.setFinishVoice(data.getVoice());
|
|
|
+ recordData.setFinishVoiceLength(data.getVoiceLength());
|
|
|
recordData.setContent(data.getContnet());
|
|
|
recordData.setMaintenancer(data.getImages().size() > 0 ? StringUtils.join(data.getImages(), ',') : null);
|
|
|
recordData.setMaintenanceState(eRecordStatu.Finished.getValue());
|
|
|
@@ -2057,6 +2551,16 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
throw new Exception("提交失败!");
|
|
|
}
|
|
|
|
|
|
+ RepairSystemMessages rsm = new RepairSystemMessages();
|
|
|
+ rsm.setIsRead(0);
|
|
|
+ rsm.setRecordId(data.getRecordId());
|
|
|
+ rsm.setRecipientId(recordData.getUserId());
|
|
|
+ rsm.setContent("服务已经完成,期待再次为您服务,请为我们的服务点评~");
|
|
|
+ int insertRsm = repairSystemMessagesService.insertRepairSystemMessages(rsm);
|
|
|
+ if (insertRsm <= 0) {
|
|
|
+ throw new Exception("提交失败!");
|
|
|
+ }
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
throw new Exception("提交失败!");
|
|
|
}
|
|
|
@@ -2091,6 +2595,7 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
RepairTransferRecord rtr = new RepairTransferRecord();
|
|
|
rtr.setRecordId(data.getRecordId());
|
|
|
rtr.setVoice(data.getVoice());
|
|
|
+ rtr.setVoiceLength(data.getVoiceLength());
|
|
|
rtr.setRemark(data.getRemark());
|
|
|
rtr.setUserId(data.getUserId());
|
|
|
rtr.setApprovalStatu(2);
|
|
|
@@ -2106,6 +2611,26 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
throw new Exception("申请失败!");
|
|
|
}
|
|
|
|
|
|
+ //给郭班长和后勤发消息
|
|
|
+ List<Integer> userZZ = new ArrayList<>();
|
|
|
+ userZZ.add(2);
|
|
|
+ userZZ.add(3);
|
|
|
+ List<RepairUser> users = repairUserService.getRepairByUserZZ(userZZ, recordData.getSchoolId());
|
|
|
+ List<RepairSystemMessages> rsms = new ArrayList<>();
|
|
|
+ for (RepairUser user : users) {
|
|
|
+ RepairSystemMessages rsm = new RepairSystemMessages();
|
|
|
+ rsm.setIsRead(0);
|
|
|
+ rsm.setRecordId(result);
|
|
|
+ rsm.setRecipientId(user.getId());
|
|
|
+ rsm.setContent("您有一个审核工单,请尽快处理!");
|
|
|
+ rsms.add(rsm);
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean insertRsm = repairSystemMessagesService.inserBatchSystemMessage(rsms);
|
|
|
+ if (!insertRsm) {
|
|
|
+ throw new Exception("转单审核发起失败!");
|
|
|
+ }
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
throw new Exception("转单审核发起失败!");
|
|
|
}
|
|
|
@@ -2146,6 +2671,7 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
RepairCollaborateRecord rcr = new RepairCollaborateRecord();
|
|
|
rcr.setRecordId(data.getRecordId());
|
|
|
rcr.setVoice(data.getVoice());
|
|
|
+ rcr.setVoiceLength(data.getVoiceLength());
|
|
|
rcr.setRemark(data.getRemark());
|
|
|
rcr.setUserId(data.getUserId());
|
|
|
rcr.setApprovalStatu(2);
|
|
|
@@ -2162,6 +2688,26 @@ public class RepairRecordController implements RepairRecordControllerAPI {
|
|
|
throw new Exception("申请失败!");
|
|
|
}
|
|
|
|
|
|
+ //给郭班长和后勤发消息
|
|
|
+ List<Integer> userZZ = new ArrayList<>();
|
|
|
+ userZZ.add(2);
|
|
|
+ userZZ.add(3);
|
|
|
+ List<RepairUser> users = repairUserService.getRepairByUserZZ(userZZ, recordData.getSchoolId());
|
|
|
+ List<RepairSystemMessages> rsms = new ArrayList<>();
|
|
|
+ for (RepairUser user : users) {
|
|
|
+ RepairSystemMessages rsm = new RepairSystemMessages();
|
|
|
+ rsm.setIsRead(0);
|
|
|
+ rsm.setRecordId(result);
|
|
|
+ rsm.setRecipientId(user.getId());
|
|
|
+ rsm.setContent("您有一个审核工单,请尽快处理!");
|
|
|
+ rsms.add(rsm);
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean insertRsm = repairSystemMessagesService.inserBatchSystemMessage(rsms);
|
|
|
+ if (!insertRsm) {
|
|
|
+ throw new Exception("转单审核发起失败!");
|
|
|
+ }
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
throw new Exception("协作审核发起失败!");
|
|
|
}
|