|
@ -21,7 +21,6 @@ import com.yihu.jw.hospital.task.PushMsgTask;
|
|
|
import com.yihu.jw.hospital.utils.WeiXinAccessTokenUtils;
|
|
|
import com.yihu.jw.im.dao.ConsultDao;
|
|
|
import com.yihu.jw.im.util.ImUtil;
|
|
|
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.patient.service.BasePatientService;
|
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
@ -29,7 +28,6 @@ import com.yihu.jw.restmodel.qvo.ParamQvo;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.util.common.QrcodeUtil;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
|
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
|
import com.yihu.jw.utils.EntityUtils;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
@ -648,120 +646,137 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
|
|
|
* @param jsonData
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
|
// public JSONObject create(String jsonData) throws Exception {
|
|
|
// logger.info("创建上门服务jsonData参数:" + jsonData);
|
|
|
//
|
|
|
// JSONObject result = new JSONObject();
|
|
|
// JSONObject jsonObjectParam = JSONObject.parseObject(jsonData);
|
|
|
//
|
|
|
// WlyyDoorServiceOrderDO orderDO = EntityUtils.jsonToEntity(
|
|
|
// jsonObjectParam.get("order").toString(), WlyyDoorServiceOrderDO.class);
|
|
|
//
|
|
|
// orderDO.setNumber(getRandomIntStr());
|
|
|
// orderDO.setCreateTime(new Date());
|
|
|
// orderDO.setCreateUser(orderDO.getProxyPatient());
|
|
|
// orderDO.setCreateUserName(orderDO.getProxyPatientName());
|
|
|
// orderDO.setOrderInfo("0");
|
|
|
//
|
|
|
// if (StringUtils.isEmpty(orderDO.getPatient())) {
|
|
|
// throw new Exception("当前服务对象code为空,请联系管理员检查参数!patient = " + orderDO.getPatient());
|
|
|
// }
|
|
|
//
|
|
|
// if (StringUtils.isEmpty(orderDO.getProxyPatient())) {
|
|
|
// String failMsg = "当前代理对象code为空,请联系管理员检查参数!proxyPatient = " + orderDO.getProxyPatient();
|
|
|
// throw new Exception(failMsg);
|
|
|
// }
|
|
|
//
|
|
|
// //判断师傅存在为完成的上门服务订单
|
|
|
// boolean bool = wlyyDoorServiceOrderDao.existsByPatientAndStatusIn(orderDO.getPatient(),
|
|
|
// new Integer[]{WlyyDoorServiceOrderDO.Status.waitForSend.getType(),
|
|
|
// WlyyDoorServiceOrderDO.Status.waitForAccept.getType(),
|
|
|
// WlyyDoorServiceOrderDO.Status.waitForServe.getType(),
|
|
|
// WlyyDoorServiceOrderDO.Status.accept.getType(),
|
|
|
// });
|
|
|
//
|
|
|
// if (bool) {
|
|
|
// String failMsg = "当前服务对象存在未完成的上门服务,请先完成该服务!";
|
|
|
// throw new Exception(failMsg);
|
|
|
// }
|
|
|
//
|
|
|
// orderDO.setHospital(jsonObjectParam.getJSONObject("hospital").get("code").toString());
|
|
|
// orderDO.setCreateTime(new Date());
|
|
|
// //判断创建上门服务类型,发起类型(1本人发起 2家人待预约 3医生代预约)
|
|
|
// if (orderDO.getProxyPatient().equals(orderDO.getPatient())) {
|
|
|
// orderDO.setType(1);
|
|
|
// } else if (!orderDO.getProxyPatient().equals(orderDO.getPatient())) {
|
|
|
// orderDO.setType(2);
|
|
|
// }
|
|
|
// orderDO.setServiceStatus("1");
|
|
|
// //保存服务订单
|
|
|
// wlyyDoorServiceOrderDao.save(orderDO);
|
|
|
//
|
|
|
// //创建咨询
|
|
|
// JSONObject successOrNot = consultTeamService.addDoorServiceConsult(orderDO.getId());
|
|
|
// ConsultTeamDo consultTeam = (ConsultTeamDo) successOrNot.get(ResponseContant.resultMsg);
|
|
|
//
|
|
|
// //新增工单与服务项费用关联关系
|
|
|
// if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO)) {
|
|
|
// return result;
|
|
|
// }
|
|
|
// //获取机构的调度员
|
|
|
// List<Map<String, Object>> dispatcherList = queryDispatcherInfoByPatient(jsonObjectParam.getJSONObject("hospital").get("code").toString());
|
|
|
// //没有调度员的模式
|
|
|
//// if (dispatcherList.isEmpty()
|
|
|
//// && StringUtils.isEmpty(orderDO.getDoctor())
|
|
|
//// && StringUtils.isEmpty(orderDO.getExpectedDoctorName())) {
|
|
|
//// orderDO.setStatus(2);
|
|
|
//// //应该是康复模板的康复下转,才有签约--先注释
|
|
|
//// orderDO.setDoctor(signFamily.getDoctor());
|
|
|
//// orderDO.setDoctorName(signFamily.getDoctorName());
|
|
|
//// this.save(orderDO);
|
|
|
//// WlyyDoorServiceOrderDO wlyyDoorServiceOrder = wlyyDoorServiceOrderDao.findById(orderDO.getId());
|
|
|
//// //新增工单医生关联关系
|
|
|
//// if (orderWithDoctorAdd(result, jsonObjectParam, wlyyDoorServiceOrder)) {
|
|
|
//// return result;
|
|
|
//// }
|
|
|
//// // 给服务医生发接单消息--先注释
|
|
|
//// this.createMessage(orderDO.getId(), orderDO.getProxyPatient(), signFamily.getDoctor(), 407, "服务工单待接单", "您有新的服务工单,请前往处理");
|
|
|
//// //发送智能助手消息-微信消息先注释
|
|
|
//// sendWeixinMessage(4, signFamily.getDoctor(), orderDO.getPatient());
|
|
|
//// result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
//// result.put(ResponseContant.resultMsg, consultTeam);
|
|
|
//// return result;
|
|
|
//// }
|
|
|
//
|
|
|
// //有调度员
|
|
|
// if (!dispatcherList.isEmpty()) {
|
|
|
// for (Map<String, Object> map : dispatcherList) {
|
|
|
// String dispatcher = map.get("code").toString();
|
|
|
// // 派单消息-首页
|
|
|
// this.createMessage(orderDO.getId(), "system", dispatcher, 402, "新增居民预约服务申请", orderDO.getPatientName() + "提交了服务预约申请,请您前往处理");
|
|
|
// // 派单-实时工单消息 430 居民提交工单申请-- 张三提交了服务工单12345678申请
|
|
|
// this.createMessage(orderDO.getId(), "system", dispatcher, 430, "居民提交工单申请", orderDO.getPatientName() + "提交了服务工单" + orderDO.getNumber() + "申请");
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// //给机构调度员发送医生助手消息
|
|
|
// for (Map<String, Object> map : dispatcherList) {
|
|
|
// //这边还没有微信消息的功能呢。
|
|
|
// sendWeixinMessage(3, map.get("user_code") + "", orderDO.getPatient());
|
|
|
// }
|
|
|
// result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
// result.put(ResponseContant.resultMsg, consultTeam);
|
|
|
//
|
|
|
// //发送 预约卡片信息(2101类型)
|
|
|
// JSONObject orderInfoContent = this.queryOrderCardInfo(orderDO);
|
|
|
// orderInfoContent.put("re_msg_type", 0);//居民预约
|
|
|
// //发送消息
|
|
|
// int i = qucikSendIM(orderDO.getId(), "system", "智能助手", "2101", orderInfoContent.toJSONString());
|
|
|
//// if (i != 1) {
|
|
|
//// throw new Exception("上门服务工单消息发送失败");
|
|
|
//// }
|
|
|
//
|
|
|
// if (StringUtils.isNoneBlank(orderDO.getDoctor())) {
|
|
|
// //服务医生修改,直接转派
|
|
|
// BaseDoctorDO transDoctor = doctorDao.findById(orderDO.getDoctor());
|
|
|
// sendOrderToDoctor(orderDO.getId(), null, "system", "系统", transDoctor.getId(), transDoctor.getName(), transDoctor.getJobTitleName());
|
|
|
// }
|
|
|
// return result;
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
public JSONObject create(String jsonData) throws Exception {
|
|
|
logger.info("创建上门服务jsonData参数:" + jsonData);
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
JSONObject jsonObjectParam = JSONObject.parseObject(jsonData);
|
|
|
|
|
|
WlyyDoorServiceOrderDO orderDO = EntityUtils.jsonToEntity(
|
|
|
jsonObjectParam.get("order").toString(), WlyyDoorServiceOrderDO.class);
|
|
|
|
|
|
orderDO.setNumber(getRandomIntStr());
|
|
|
orderDO.setCreateTime(new Date());
|
|
|
orderDO.setCreateUser(orderDO.getProxyPatient());
|
|
|
orderDO.setCreateUserName(orderDO.getProxyPatientName());
|
|
|
orderDO.setOrderInfo("0");
|
|
|
|
|
|
if (StringUtils.isEmpty(orderDO.getPatient())) {
|
|
|
throw new Exception("当前服务对象code为空,请联系管理员检查参数!patient = " + orderDO.getPatient());
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isEmpty(orderDO.getProxyPatient())) {
|
|
|
String failMsg = "当前代理对象code为空,请联系管理员检查参数!proxyPatient = " + orderDO.getProxyPatient();
|
|
|
throw new Exception(failMsg);
|
|
|
}
|
|
|
|
|
|
//判断师傅存在为完成的上门服务订单
|
|
|
boolean bool = wlyyDoorServiceOrderDao.existsByPatientAndStatusIn(orderDO.getPatient(),
|
|
|
new Integer[]{WlyyDoorServiceOrderDO.Status.waitForSend.getType(),
|
|
|
WlyyDoorServiceOrderDO.Status.waitForAccept.getType(),
|
|
|
WlyyDoorServiceOrderDO.Status.waitForServe.getType(),
|
|
|
WlyyDoorServiceOrderDO.Status.accept.getType(),
|
|
|
});
|
|
|
|
|
|
if (bool) {
|
|
|
String failMsg = "当前服务对象存在未完成的上门服务,请先完成该服务!";
|
|
|
throw new Exception(failMsg);
|
|
|
}
|
|
|
|
|
|
orderDO.setHospital(jsonObjectParam.getJSONObject("hospital").get("code").toString());
|
|
|
orderDO.setCreateTime(new Date());
|
|
|
//判断创建上门服务类型,发起类型(1本人发起 2家人待预约 3医生代预约)
|
|
|
if (orderDO.getProxyPatient().equals(orderDO.getPatient())) {
|
|
|
orderDO.setType(1);
|
|
|
} else if (!orderDO.getProxyPatient().equals(orderDO.getPatient())) {
|
|
|
orderDO.setType(2);
|
|
|
}
|
|
|
orderDO.setServiceStatus("1");
|
|
|
WlyyDoorServiceOrderDO orderDO =new WlyyDoorServiceOrderDO();
|
|
|
//保存服务订单
|
|
|
wlyyDoorServiceOrderDao.save(orderDO);
|
|
|
//创建咨询
|
|
|
JSONObject successOrNot = consultTeamService.addDoorServiceConsult(orderDO.getId());
|
|
|
ConsultTeamDo consultTeam = (ConsultTeamDo) successOrNot.get(ResponseContant.resultMsg);
|
|
|
|
|
|
//新增工单与服务项费用关联关系
|
|
|
if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO)) {
|
|
|
return result;
|
|
|
}
|
|
|
//获取机构的调度员
|
|
|
List<Map<String, Object>> dispatcherList = queryDispatcherInfoByPatient(jsonObjectParam.getJSONObject("hospital").get("code").toString());
|
|
|
//没有调度员的模式
|
|
|
// if (dispatcherList.isEmpty()
|
|
|
// && StringUtils.isEmpty(orderDO.getDoctor())
|
|
|
// && StringUtils.isEmpty(orderDO.getExpectedDoctorName())) {
|
|
|
// orderDO.setStatus(2);
|
|
|
// //应该是康复模板的康复下转,才有签约--先注释
|
|
|
// orderDO.setDoctor(signFamily.getDoctor());
|
|
|
// orderDO.setDoctorName(signFamily.getDoctorName());
|
|
|
// this.save(orderDO);
|
|
|
// WlyyDoorServiceOrderDO wlyyDoorServiceOrder = wlyyDoorServiceOrderDao.findById(orderDO.getId());
|
|
|
// //新增工单医生关联关系
|
|
|
// if (orderWithDoctorAdd(result, jsonObjectParam, wlyyDoorServiceOrder)) {
|
|
|
// return result;
|
|
|
// }
|
|
|
// // 给服务医生发接单消息--先注释
|
|
|
// this.createMessage(orderDO.getId(), orderDO.getProxyPatient(), signFamily.getDoctor(), 407, "服务工单待接单", "您有新的服务工单,请前往处理");
|
|
|
// //发送智能助手消息-微信消息先注释
|
|
|
// sendWeixinMessage(4, signFamily.getDoctor(), orderDO.getPatient());
|
|
|
// result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
// result.put(ResponseContant.resultMsg, consultTeam);
|
|
|
// return result;
|
|
|
// }
|
|
|
|
|
|
//有调度员
|
|
|
if (!dispatcherList.isEmpty()) {
|
|
|
for (Map<String, Object> map : dispatcherList) {
|
|
|
String dispatcher = map.get("code").toString();
|
|
|
// 派单消息-首页
|
|
|
this.createMessage(orderDO.getId(), "system", dispatcher, 402, "新增居民预约服务申请", orderDO.getPatientName() + "提交了服务预约申请,请您前往处理");
|
|
|
// 派单-实时工单消息 430 居民提交工单申请-- 张三提交了服务工单12345678申请
|
|
|
this.createMessage(orderDO.getId(), "system", dispatcher, 430, "居民提交工单申请", orderDO.getPatientName() + "提交了服务工单" + orderDO.getNumber() + "申请");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//给机构调度员发送医生助手消息
|
|
|
for (Map<String, Object> map : dispatcherList) {
|
|
|
//这边还没有微信消息的功能呢。
|
|
|
sendWeixinMessage(3, map.get("user_code") + "", orderDO.getPatient());
|
|
|
}
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
result.put(ResponseContant.resultMsg, consultTeam);
|
|
|
|
|
|
//发送 预约卡片信息(2101类型)
|
|
|
JSONObject orderInfoContent = this.queryOrderCardInfo(orderDO);
|
|
|
orderInfoContent.put("re_msg_type", 0);//居民预约
|
|
|
//发送消息
|
|
|
int i = qucikSendIM(orderDO.getId(), "system", "智能助手", "2101", orderInfoContent.toJSONString());
|
|
|
// if (i != 1) {
|
|
|
// throw new Exception("上门服务工单消息发送失败");
|
|
|
// }
|
|
|
|
|
|
if (StringUtils.isNoneBlank(orderDO.getDoctor())) {
|
|
|
//服务医生修改,直接转派
|
|
|
BaseDoctorDO transDoctor = doctorDao.findById(orderDO.getDoctor());
|
|
|
sendOrderToDoctor(orderDO.getId(), null, "system", "系统", transDoctor.getId(), transDoctor.getName(), transDoctor.getJobTitleName());
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@ -1979,7 +1994,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
if (parArray!=null){
|
|
|
if (parArray != null) {
|
|
|
parArray.forEach(
|
|
|
oneParObj -> {
|
|
|
org.json.JSONObject oneParJson = (org.json.JSONObject) oneParObj;
|