|
@@ -3,11 +3,13 @@ package com.care.bms.service;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.care.bigscreen.service.BigScreenService;
|
|
|
import com.care.common.cache.RedisKeyConstant;
|
|
|
import com.care.common.cache.RedisUtil;
|
|
|
import com.care.common.entity.*;
|
|
@@ -20,7 +22,6 @@ import com.care.common.vo.event.*;
|
|
|
import com.care.common.vo.outcall.CcCallResultVO;
|
|
|
import org.apache.commons.compress.utils.Lists;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -37,10 +38,10 @@ import java.util.List;
|
|
|
@Service
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public class BmsEventOrderService {
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
RedisUtil redisUtil;
|
|
|
@Resource
|
|
|
- private CareOlderContactService careOlderContactService;
|
|
|
+ private CareHouseContactService careHouseContactService;
|
|
|
@Resource
|
|
|
private CareOlderService careOlderService;
|
|
|
@Resource
|
|
@@ -48,8 +49,6 @@ public class BmsEventOrderService {
|
|
|
@Resource
|
|
|
private CareSysUserService careSysUserService;
|
|
|
@Resource
|
|
|
- private CareChamberlainOlderRelService careChamberlainOlderRelService;
|
|
|
- @Resource
|
|
|
private CareEventOrderContactStatusService careEventOrderContactStatusService;
|
|
|
@Resource
|
|
|
private CareEventOrderHandleHisService careEventOrderHandleHisService;
|
|
@@ -57,6 +56,17 @@ public class BmsEventOrderService {
|
|
|
private CareEventOrderKeyApplyService careEventOrderKeyApplyService;
|
|
|
@Resource
|
|
|
private CcCallResultService ccCallResultService;
|
|
|
+ @Resource
|
|
|
+ private CareHouseService careHouseService;
|
|
|
+ @Resource
|
|
|
+ private CareEventOrderOlderService careEventOrderOlderService;
|
|
|
+ @Resource
|
|
|
+ private CareEventOrderChambService careEventOrderChambService;
|
|
|
+
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private BigScreenService bigScreenService;
|
|
|
+
|
|
|
/**
|
|
|
* 工单查询
|
|
|
* @param orderStatus
|
|
@@ -130,7 +140,6 @@ public class BmsEventOrderService {
|
|
|
* @param orderId
|
|
|
* @param loginUser
|
|
|
*/
|
|
|
-
|
|
|
public void receiveOrder(Long orderId, UserLogindConvertVO loginUser) {
|
|
|
String key = RedisKeyConstant.DO_ORDER+":"+orderId;
|
|
|
boolean result = redisUtil.tryLock(key,3000);
|
|
@@ -141,19 +150,11 @@ public class BmsEventOrderService {
|
|
|
if (OrderStatusEnum.TODO.getValue().equals(order.getStatus())){
|
|
|
UpdateWrapper<CareEventOrder> updateWrapper = new UpdateWrapper<>();
|
|
|
updateWrapper.lambda().eq(CareEventOrder::getId,orderId)
|
|
|
- .set(CareEventOrder::getStatus,OrderStatusEnum.DOING)
|
|
|
+ .set(CareEventOrder::getStatus,OrderStatusEnum.DOING.getValue())
|
|
|
.set(CareEventOrder::getSeatId,loginUser.getId())
|
|
|
+ .set(CareEventOrder::getSeatName,loginUser.getName())
|
|
|
.set(CareEventOrder::getModifyTime,DateUtil.date());
|
|
|
this.careEventOrderService.update(updateWrapper);
|
|
|
- //2. 将老人的联系人、管家 插入到 事件工单 联系人中
|
|
|
- List<CareEventOrderContactStatus> orderContactList = Lists.newArrayList();
|
|
|
- //查询老人
|
|
|
- addOlderToOrderContact(order,orderContactList);
|
|
|
- //查询管家
|
|
|
- addChamberlainToOrderContact(order,orderContactList);
|
|
|
- //查询紧急联系人
|
|
|
- addContactToOrderContact(order,orderContactList);
|
|
|
- this.careEventOrderContactStatusService.saveBatch(orderContactList);
|
|
|
}else{
|
|
|
throw new BDException("该工单状态已变化,请刷新");
|
|
|
}
|
|
@@ -167,39 +168,55 @@ public class BmsEventOrderService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 查询老人信息
|
|
|
+ *
|
|
|
* @param orderId
|
|
|
* @return
|
|
|
*/
|
|
|
- public OrderOlderVO getOrderOlderInfo(Long orderId){
|
|
|
- OrderOlderVO orderOlderVo = new OrderOlderVO();
|
|
|
+ public EventOrderVO getOrderInfo(Long orderId){
|
|
|
+ EventOrderVO eventOrderVO = null;
|
|
|
CareEventOrder order = this.careEventOrderService.getById(orderId);
|
|
|
if (order!=null){
|
|
|
- CareOlder older = this.careOlderService.getById(order.getOlderId());
|
|
|
- BeanUtil.copyProperties(older,orderOlderVo);
|
|
|
- orderOlderVo.setEventType(order.getOrderType());
|
|
|
- orderOlderVo.setEventTypeDesc(OrderTypeEnum.getCodeToName(order.getOrderType()));
|
|
|
- //查看老人联系状态
|
|
|
- QueryWrapper<CareEventOrderContactStatus> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.lambda().eq(CareEventOrderContactStatus::getOrderId,orderId)
|
|
|
- .eq(CareEventOrderContactStatus::getContactRole,UserRoleEnum.OLDER.getValue())
|
|
|
- .eq(CareEventOrderContactStatus::getContactId,older.getId());
|
|
|
- List<CareEventOrderContactStatus> ceocs = this.careEventOrderContactStatusService.list(queryWrapper);
|
|
|
- if (CollUtil.isNotEmpty(ceocs)){
|
|
|
- CareEventOrderContactStatus contactStatus = ceocs.get(0);
|
|
|
- orderOlderVo.setContactStatus(contactStatus.getStatus());
|
|
|
- orderOlderVo.setContactStatusDesc(ContactorStatusEnum.getCodeToName(contactStatus.getStatus()));
|
|
|
- }
|
|
|
+ eventOrderVO = new EventOrderVO();
|
|
|
+ BeanUtil.copyProperties(order,eventOrderVO);
|
|
|
+ eventOrderVO.setStatusName(OrderStatusEnum.getCodeToName(eventOrderVO.getStatus()));
|
|
|
+ eventOrderVO.setOrderType(OrderTypeEnum.getCodeToName(eventOrderVO.getOrderType()));
|
|
|
+ CareHouse house = this.careHouseService.getById(order.getHouseId());
|
|
|
+ eventOrderVO.setHouse(house);
|
|
|
+ }
|
|
|
+ return eventOrderVO;
|
|
|
+ }
|
|
|
|
|
|
- //查询管家
|
|
|
+ /**
|
|
|
+ * 查询老人列表
|
|
|
+ * @param orderId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<OrderOlderVO> queryOrderOlderList(Long orderId){
|
|
|
+ List<OrderOlderVO> orderOlderVOList = Lists.newArrayList();
|
|
|
+ CareEventOrder order = this.careEventOrderService.getById(orderId);
|
|
|
+ OrderOlderVO orderOlderVo = new OrderOlderVO();
|
|
|
+ QueryWrapper<CareEventOrderOlder> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(CareEventOrderOlder::getOrderId,orderId);
|
|
|
+ List<CareEventOrderOlder> ceoos = this.careEventOrderOlderService.list(queryWrapper);
|
|
|
+ if (CollUtil.isNotEmpty(ceoos)){
|
|
|
ChamberlainVO chamberlainVO = new ChamberlainVO();
|
|
|
- CareSysUser user = this.careChamberlainOlderRelService.getMainChamberlainByOlderId(older.getId());
|
|
|
- if (user!= null){
|
|
|
- BeanUtil.copyProperties(user,chamberlainVO);
|
|
|
- orderOlderVo.setChamberlain(chamberlainVO);
|
|
|
+ CareHouse house = this.careHouseService.getById(order.getHouseId());
|
|
|
+ if (house!=null){
|
|
|
+ CareSysUser user = this.careSysUserService.getById(house.getChambId());
|
|
|
+ if (user!= null){
|
|
|
+ BeanUtil.copyProperties(user,chamberlainVO);
|
|
|
+ }
|
|
|
}
|
|
|
+ ceoos.forEach(item->{
|
|
|
+ OrderOlderVO orderOlderVO = new OrderOlderVO();
|
|
|
+ BeanUtil.copyProperties(item,orderOlderVO);
|
|
|
+ orderOlderVO.setStatusDesc(OrderOlderStatusEnum.getCodeToName(orderOlderVO.getStatus()));
|
|
|
+ orderOlderVO.setChamberlain(chamberlainVO);
|
|
|
+ orderOlderVOList.add(orderOlderVO);
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
- return orderOlderVo;
|
|
|
+ return orderOlderVOList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -238,6 +255,7 @@ public class BmsEventOrderService {
|
|
|
OrderContactorVO contactorVO = new OrderContactorVO();
|
|
|
BeanUtil.copyProperties(item,contactorVO);
|
|
|
contactorVO.setStatusDesc(ContactorStatusEnum.getCodeToName(item.getStatus()));
|
|
|
+ result.add(contactorVO);
|
|
|
});
|
|
|
}
|
|
|
return result;
|
|
@@ -249,11 +267,20 @@ public class BmsEventOrderService {
|
|
|
* @param orderStatusEnum
|
|
|
*/
|
|
|
public void updateOrderStatus(Long orderId,OrderStatusEnum orderStatusEnum){
|
|
|
+ CareEventOrder order = this.careEventOrderService.getById(orderId);
|
|
|
UpdateWrapper<CareEventOrder> updateWrapper = new UpdateWrapper<>();
|
|
|
updateWrapper.lambda().eq(CareEventOrder::getId,orderId)
|
|
|
.set(CareEventOrder::getStatus,orderStatusEnum.getValue())
|
|
|
.set(CareEventOrder::getModifyTime,DateUtil.date());
|
|
|
+ this.careEventOrderService.update(updateWrapper);
|
|
|
+ this.bigScreenService.pushRtEventFlag(order.getStationId().toString());
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取钥匙请求历史
|
|
|
+ * @param orderId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public List<OrderKeyApplyVO> queryKeyAuthList(Long orderId){
|
|
|
List<OrderKeyApplyVO> result = Lists.newArrayList();
|
|
|
QueryWrapper<CareEventOrderKeyApply> queryWrapper = new QueryWrapper<>();
|
|
@@ -273,10 +300,26 @@ public class BmsEventOrderService {
|
|
|
* @param applyId
|
|
|
* @return
|
|
|
*/
|
|
|
- public boolean keyAuth(Long applyId){
|
|
|
+ public boolean keyAuth(Long applyId ,UserLogindConvertVO loginUser){
|
|
|
+ CareEventOrderKeyApply apply = this.careEventOrderKeyApplyService.getById(applyId);
|
|
|
UpdateWrapper<CareEventOrderKeyApply> updateWrapper = new UpdateWrapper<>();
|
|
|
updateWrapper.lambda().eq(CareEventOrderKeyApply::getId,applyId)
|
|
|
.set(CareEventOrderKeyApply::getStatus,KeyAuthEnum.AUTHED.getValue());
|
|
|
+ //TODO 增加日志
|
|
|
+ CareEventOrderHandleHis his = new CareEventOrderHandleHis();
|
|
|
+ his.setOrgId(apply.getOrgId());
|
|
|
+ his.setStationId(apply.getStationId());
|
|
|
+ his.setOrderId(apply.getOrderId());
|
|
|
+ // his.setLogType();
|
|
|
+ his.setLogObjectId(apply.getApplyUserId());
|
|
|
+ his.setLogObjectName(apply.getApplyUserName());
|
|
|
+ // his.setLogResult();
|
|
|
+ his.setOpUserRole(UserRoleEnum.SEAT.getValue());
|
|
|
+ his.setOpUserId(loginUser.getId());
|
|
|
+ his.setOpUserName(loginUser.getName());
|
|
|
+ his.setCreateTime(DateUtil.date());
|
|
|
+ his.setRelationTypeDesc(apply.getRelationTypeDesc());
|
|
|
+ this.careEventOrderHandleHisService.save(his);
|
|
|
return this.careEventOrderKeyApplyService.update(updateWrapper);
|
|
|
}
|
|
|
|
|
@@ -286,10 +329,25 @@ public class BmsEventOrderService {
|
|
|
* @param status
|
|
|
* @return
|
|
|
*/
|
|
|
- public boolean updateOrderContactStatus(Long orderContactId,Integer status){
|
|
|
+ public boolean updateOrderContactStatus(Long orderContactId,Integer status,UserLogindConvertVO loginUser){
|
|
|
+ CareEventOrderContactStatus contact = this.careEventOrderContactStatusService.getById(orderContactId);
|
|
|
UpdateWrapper<CareEventOrderContactStatus> updateWrapper = new UpdateWrapper<>();
|
|
|
updateWrapper.lambda().eq(CareEventOrderContactStatus::getId,orderContactId)
|
|
|
.set(CareEventOrderContactStatus::getStatus,status);
|
|
|
+
|
|
|
+ CareEventOrderHandleHis his = new CareEventOrderHandleHis();
|
|
|
+ his.setOrgId(contact.getOrgId());
|
|
|
+ his.setStationId(contact.getStationId());
|
|
|
+ his.setOrderId(contact.getOrderId());
|
|
|
+ // his.setLogType();
|
|
|
+ his.setLogObjectId(contact.getContactId());
|
|
|
+ his.setLogObjectName(contact.getContactName());
|
|
|
+ his.setLogResult(ContactorStatusEnum.getCodeToName(status));
|
|
|
+ his.setOpUserRole(UserRoleEnum.SEAT.getValue());
|
|
|
+ his.setOpUserId(loginUser.getId());
|
|
|
+ his.setOpUserName(loginUser.getName());
|
|
|
+ his.setCreateTime(DateUtil.date());
|
|
|
+ his.setRelationTypeDesc(contact.getRelationTypeDesc());
|
|
|
return this.careEventOrderContactStatusService.update(updateWrapper);
|
|
|
}
|
|
|
|
|
@@ -306,64 +364,86 @@ public class BmsEventOrderService {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ public void insertTestData(){
|
|
|
+ List<CareHouse> houses = Lists.newArrayList();
|
|
|
+ CareHouse house = new CareHouse();
|
|
|
+ house.setId(1L);
|
|
|
+ house.setName("201室");
|
|
|
+ house.setAddr("北太平庄21号院1单元201室");
|
|
|
+ houses.add(house);
|
|
|
+ CareEventOrder order = new CareEventOrder();
|
|
|
+ order.setOrgId(1L);
|
|
|
+ order.setOrgName("测试机构");
|
|
|
+ order.setStationId(1L);
|
|
|
+ order.setStationName("站点1");
|
|
|
+ order.setHouseId(1L);
|
|
|
+ order.setHouseName(house.getName());
|
|
|
+ order.setTitle(house.getAddr());
|
|
|
+ order.setOrderType(OrderTypeEnum.values()[RandomUtil.randomInt(0,4)].getValue());
|
|
|
+ order.setStatus("0");
|
|
|
+ order.setCreateTime(DateUtil.date());
|
|
|
+ order.setModifyTime(DateUtil.date());
|
|
|
+ this.careEventOrderService.save(order);
|
|
|
+ addOlderToOrderOlder(order);
|
|
|
+ addChamberlainToOrder(order);
|
|
|
+ addContactToOrderContact(order);
|
|
|
+ }
|
|
|
/**
|
|
|
- * 将老人加入到 工单联系人
|
|
|
+ * 将老人加入到 工单中
|
|
|
* @param order
|
|
|
- * @param orderContactList
|
|
|
*/
|
|
|
- private void addOlderToOrderContact(CareEventOrder order,List<CareEventOrderContactStatus> orderContactList){
|
|
|
- CareOlder older = this.careOlderService.getById(order.getOlderId());
|
|
|
- CareEventOrderContactStatus orderContactStatus = new CareEventOrderContactStatus();
|
|
|
- orderContactStatus.setOrgId(order.getOrgId());
|
|
|
- orderContactStatus.setStationId(order.getStationId());
|
|
|
- orderContactStatus.setOrderId(order.getId());
|
|
|
- orderContactStatus.setContactRole(UserRoleEnum.OLDER.getValue());
|
|
|
- orderContactStatus.setContactId(older.getId());
|
|
|
- orderContactStatus.setStatus(ContactorStatusEnum.WEI_LIAN_XI.getValue());
|
|
|
- orderContactStatus.setContactName(older.getName());
|
|
|
- orderContactStatus.setContactPhone(older.getPhone());
|
|
|
- orderContactStatus.setLongitude(older.getLongitude());
|
|
|
- orderContactStatus.setLatitude(older.getLatitude());
|
|
|
- orderContactStatus.setCreateTime(DateUtil.date());
|
|
|
- orderContactStatus.setModifyTime(DateUtil.date());
|
|
|
- orderContactStatus.setRelationTypeDesc(RelationTypeEnum.OLDER.getValue());
|
|
|
- orderContactList.add(orderContactStatus);
|
|
|
+ public void addOlderToOrderOlder(CareEventOrder order){
|
|
|
+ QueryWrapper<CareOlder> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(CareOlder::getHouseId,order.getHouseId());
|
|
|
+ List<CareOlder> olders = this.careOlderService.list(queryWrapper);
|
|
|
+ if (CollUtil.isNotEmpty(olders)){
|
|
|
+ List<CareEventOrderOlder> ceoos = Lists.newArrayList();
|
|
|
+ olders.forEach(item -> {
|
|
|
+ CareEventOrderOlder ceoo = new CareEventOrderOlder();
|
|
|
+ BeanUtil.copyProperties(item,ceoo);
|
|
|
+ ceoo.setOrderId(order.getId());
|
|
|
+ if (order.getOlderId() == item.getId()){
|
|
|
+ //主动呼叫
|
|
|
+ ceoo.setIsZhudong(1);
|
|
|
+ }else{
|
|
|
+ ceoo.setIsZhudong(0);
|
|
|
+ }
|
|
|
+ ceoo.setStatus(OrderOlderStatusEnum.WEI_LIAN_XI.getValue());
|
|
|
+ ceoo.setCreateTime(DateUtil.date());
|
|
|
+ ceoos.add(ceoo);
|
|
|
+ });
|
|
|
+ this.careEventOrderOlderService.saveBatch(ceoos);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 将管家加入到联系人当中
|
|
|
* @param order
|
|
|
- * @param orderContactList
|
|
|
*/
|
|
|
- private void addChamberlainToOrderContact(CareEventOrder order,List<CareEventOrderContactStatus> orderContactList){
|
|
|
- CareSysUser user = careChamberlainOlderRelService.getMainChamberlainByOlderId(order.getOlderId());
|
|
|
- if (user != null){
|
|
|
- CareEventOrderContactStatus orderContactStatus = new CareEventOrderContactStatus();
|
|
|
- orderContactStatus.setOrgId(order.getOrgId());
|
|
|
- orderContactStatus.setStationId(order.getStationId());
|
|
|
- orderContactStatus.setOrderId(order.getId());
|
|
|
- orderContactStatus.setContactRole(UserRoleEnum.CHANMB.getValue());
|
|
|
- orderContactStatus.setContactId(user.getId());
|
|
|
- orderContactStatus.setStatus(ContactorStatusEnum.WEI_LIAN_XI.getValue());
|
|
|
- orderContactStatus.setContactName(user.getName());
|
|
|
- orderContactStatus.setContactPhone(user.getPhone());
|
|
|
- orderContactStatus.setLongitude(user.getLongitude());
|
|
|
- orderContactStatus.setLatitude(user.getLatitude());
|
|
|
- orderContactStatus.setCreateTime(DateUtil.date());
|
|
|
- orderContactStatus.setModifyTime(DateUtil.date());
|
|
|
- orderContactStatus.setRelationTypeDesc(RelationTypeEnum.CHANMB.getValue());
|
|
|
- orderContactList.add(orderContactStatus);
|
|
|
+ public void addChamberlainToOrder(CareEventOrder order){
|
|
|
+ CareHouse house = this.careHouseService.getById(order.getHouseId());
|
|
|
+ if (house != null){
|
|
|
+ CareSysUser user = this.careSysUserService.getById(house.getChambId());
|
|
|
+ if (user != null){
|
|
|
+ CareEventOrderChamb chamb = new CareEventOrderChamb();
|
|
|
+ BeanUtil.copyProperties(user,chamb);
|
|
|
+ chamb.setHouseId(house.getId());
|
|
|
+ chamb.setStatus(0);
|
|
|
+ chamb.setCreateTime(DateUtil.date());
|
|
|
+ chamb.setModifyTime(DateUtil.date());
|
|
|
+ this.careEventOrderChambService.save(chamb);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 将紧急联系人加入到联系人当中
|
|
|
* @param order
|
|
|
- * @param orderContactList
|
|
|
*/
|
|
|
- private void addContactToOrderContact(CareEventOrder order,List<CareEventOrderContactStatus> orderContactList){
|
|
|
- List<CareOlderContact> cons = this.careOlderContactService.queryContactByOlderId(order.getOlderId());
|
|
|
+ public void addContactToOrderContact(CareEventOrder order){
|
|
|
+ List<CareHouseContact> cons = this.careHouseContactService.queryContactByHouseId(order.getHouseId());
|
|
|
if (CollUtil.isNotEmpty(cons)){
|
|
|
+ List<CareEventOrderContactStatus> orderContactList = Lists.newArrayList();
|
|
|
cons.forEach(item ->{
|
|
|
CareEventOrderContactStatus orderContactStatus = new CareEventOrderContactStatus();
|
|
|
orderContactStatus.setOrgId(order.getOrgId());
|
|
@@ -382,6 +462,7 @@ public class BmsEventOrderService {
|
|
|
orderContactStatus.setModifyTime(DateUtil.date());
|
|
|
orderContactList.add(orderContactStatus);
|
|
|
});
|
|
|
+ this.careEventOrderContactStatusService.saveBatch(orderContactList);
|
|
|
}
|
|
|
|
|
|
}
|