|
@ -394,12 +394,9 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
|
|
|
}
|
|
|
feeDetailDOList.add(feeDetailDO);
|
|
|
}
|
|
|
try {
|
|
|
wlyyDoorFeeDetailDao.saveAll(feeDetailDOList);
|
|
|
doorOrderItemDao.saveAll(orderItemDOList);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
wlyyDoorFeeDetailDao.saveAll(feeDetailDOList);
|
|
|
doorOrderItemDao.saveAll(orderItemDOList);
|
|
|
|
|
|
// //更新总费用-这边没用到
|
|
|
// order.setTotalFee(totalFee);
|
|
@ -614,9 +611,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public JSONObject queryDispatcherInfoByPatient(String hospitalCode) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
public List<Map<String, Object>> queryDispatcherInfoByPatient(String hospitalCode) {
|
|
|
String sql = "SELECT\n" +
|
|
|
" a.doctor_code 'code',\n" +
|
|
|
" b.`name` 'name',\n" +
|
|
@ -631,23 +626,14 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
|
|
|
" INNER JOIN base_doctor b ON a.doctor_code = b.id \n" +
|
|
|
"WHERE\n" +
|
|
|
" 1 = 1 \n" +
|
|
|
" AND t.`code` = 'dispatcher' \n" +
|
|
|
" AND a.org_code = '" + hospitalCode + "' \n";
|
|
|
// " AND r.doctor_code = '402803816babc778016babca8bdc003a'";
|
|
|
" AND t.`code` = 'dispatcher' \n";
|
|
|
|
|
|
List<Map<String, Object>> dispatcherInfoList = jdbcTemplate.queryForList(sql);
|
|
|
// List dispatcherInfoList = roleService.queryDispatcherInfoByHospital(hospitalCode);
|
|
|
if (CollectionUtils.isEmpty(dispatcherInfoList)) {
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
String failMsg = "当前居民所签约机构【" + hospitalCode + "】没有调度员,请联系管理员分配!";
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
logger.error(failMsg);
|
|
|
return result;
|
|
|
if (StringUtils.isNotBlank(hospitalCode)) {
|
|
|
sql += " AND a.org_code = '" + hospitalCode + "' \n";
|
|
|
}
|
|
|
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
result.put(ResponseContant.resultMsg, dispatcherInfoList);
|
|
|
return result;
|
|
|
List<Map<String, Object>> dispatcherInfoList = jdbcTemplate.queryForList(sql);
|
|
|
return dispatcherInfoList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -656,7 +642,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
|
|
|
* @param jsonData
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public JSONObject create(String jsonData) throws Exception {
|
|
|
logger.info("创建上门服务jsonData参数:" + jsonData);
|
|
|
|
|
@ -706,41 +692,40 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
|
|
|
wlyyDoorServiceOrderDao.save(orderDO);
|
|
|
//创建咨询
|
|
|
JSONObject successOrNot = consultTeamService.addDoorServiceConsult(orderDO.getId());
|
|
|
|
|
|
ConsultTeamDo consultTeam = (ConsultTeamDo) successOrNot.get(ResponseContant.resultMsg);
|
|
|
|
|
|
//新增工单与服务项费用关联关系
|
|
|
if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO)) {
|
|
|
return result;
|
|
|
}
|
|
|
//获取居民所签约的机构的调度员
|
|
|
JSONObject dispatcherJson = queryDispatcherInfoByPatient(jsonObjectParam.getJSONObject("hospital").get("code").toString());
|
|
|
//获取机构的调度员
|
|
|
List<Map<String, Object>> dispatcherList = queryDispatcherInfoByPatient(jsonObjectParam.getJSONObject("hospital").get("code").toString());
|
|
|
//没有调度员的模式
|
|
|
if ((dispatcherJson.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail)
|
|
|
&& StringUtils.isEmpty(orderDO.getDoctor()) && StringUtils.isEmpty(orderDO.getExpectedDoctorName())) {
|
|
|
orderDO.setStatus(2);
|
|
|
//应该是康复模板的康复下转,才有签约--先注释
|
|
|
// 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()).orElse(null);
|
|
|
//新增工单医生关联关系
|
|
|
if (orderWithDoctorAdd(result, jsonObjectParam, wlyyDoorServiceOrder)) {
|
|
|
return result;
|
|
|
}
|
|
|
// 给服务医生发接单消息--先注释
|
|
|
// this.save(orderDO);
|
|
|
// WlyyDoorServiceOrderDO wlyyDoorServiceOrder = wlyyDoorServiceOrderDao.findById(orderDO.getId()).orElse(null);
|
|
|
// //新增工单医生关联关系
|
|
|
// 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;
|
|
|
}
|
|
|
// result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
// result.put(ResponseContant.resultMsg, consultTeam);
|
|
|
// return result;
|
|
|
// }
|
|
|
|
|
|
//todo 解决报错,resultMsg是字符串
|
|
|
if (dispatcherJson.getIntValue(ResponseContant.resultFlag) != ResponseContant.fail) {
|
|
|
List<Map<String, Object>> dispatcherInfoList = (List) dispatcherJson.get(ResponseContant.resultMsg);
|
|
|
for (Map<String, Object> map : dispatcherInfoList) {
|
|
|
//有调度员
|
|
|
if (!dispatcherList.isEmpty()) {
|
|
|
for (Map<String, Object> map : dispatcherList) {
|
|
|
String dispatcher = map.get("code").toString();
|
|
|
// 派单消息-首页
|
|
|
this.createMessage(orderDO.getId(), "system", dispatcher, 402, "新增居民预约服务申请", orderDO.getPatientName() + "提交了服务预约申请,请您前往处理");
|
|
@ -748,10 +733,10 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
|
|
|
this.createMessage(orderDO.getId(), "system", dispatcher, 430, "居民提交工单申请", orderDO.getPatientName() + "提交了服务工单" + orderDO.getNumber() + "申请");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//给机构调度员发送医生助手消息
|
|
|
String dispatcherSql = "SELECT u.user_code FROM `manage_role_user` u ,wlyy_doctor d where u.role_id = 22 and u.user_code = d.`code` and d.hospital = '" + orderDO.getHospital() + "'";
|
|
|
List<Map<String, Object>> dispatcherList = jdbcTemplate.queryForList(dispatcherSql);
|
|
|
for (Map<String, Object> map : dispatcherList) {
|
|
|
//这边还没有微信消息的功能呢。
|
|
|
sendWeixinMessage(3, map.get("user_code") + "", orderDO.getPatient());
|
|
|
}
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
@ -760,7 +745,11 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
|
|
|
//发送 预约卡片信息(2101类型)
|
|
|
JSONObject orderInfoContent = this.queryOrderCardInfo(orderDO);
|
|
|
orderInfoContent.put("re_msg_type", 0);//居民预约
|
|
|
this.qucikSendIM(orderDO.getId(), "system", "智能助手", "2101", orderInfoContent.toJSONString());
|
|
|
//发送消息
|
|
|
int i = qucikSendIM(orderDO.getId(), "system", "智能助手", "2101", orderInfoContent.toJSONString());
|
|
|
// if (i != 1) {
|
|
|
// throw new Exception("上门服务工单消息发送失败");
|
|
|
// }
|
|
|
|
|
|
if (StringUtils.isNoneBlank(orderDO.getDoctor())) {
|
|
|
//服务医生修改,直接转派
|
|
@ -879,7 +868,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
|
|
|
* @param dispatcher
|
|
|
* @param orderId
|
|
|
*/
|
|
|
public JSONObject dispatcherIntoTopic(String orderId, String hospitalName, String dispatcher, String dispatcherName) {
|
|
|
public JSONObject dispatcherIntoTopic(String orderId, String hospitalName, String dispatcher, String dispatcherName) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
WlyyDoorServiceOrderDO orderDO = wlyyDoorServiceOrderDao.findById(orderId).orElse(null);
|
|
|
if (null == orderDO) {
|
|
@ -1047,8 +1036,8 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
|
|
|
}
|
|
|
if (!CollectionUtils.isEmpty(feeDetailDOS)) {
|
|
|
//2023-10-11 先注释 计算服务费用
|
|
|
// Map<String, Object> map = doorOrderService.countServerPackagePrice(jsonData, orderDO.getPatient());
|
|
|
// orderBriefInfo.put("packageFee", map.get("serverPackagePrice"));
|
|
|
Map<String, Object> map = doorOrderService.countServerPackagePrice(jsonData, orderDO.getPatient());
|
|
|
orderBriefInfo.put("packageFee", map.get("serverPackagePrice"));
|
|
|
}
|
|
|
orderJson.put("order", orderBriefInfo);
|
|
|
|
|
@ -1272,17 +1261,15 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
|
|
|
" o.`status` AS status, " +
|
|
|
" o.`pay_way` AS payWay, o.type," +
|
|
|
" ifnull(de.order_id,concat(rand(),'_notExist')) AS feeOrderId, " +
|
|
|
" dm.phone AS hospitalPhone, " +
|
|
|
" a.mobile AS hospitalPhone, " +
|
|
|
" count(de.number) as itemCount " +
|
|
|
" FROM " +
|
|
|
" ( wlyy_door_service_order o " +
|
|
|
" LEFT JOIN wlyy_doctor d ON o.doctor = d.`code`) " +
|
|
|
" LEFT JOIN wlyy_door_fee_detail de on o.id = de.order_id " +
|
|
|
" LEFT JOIN dm_hospital dm on o.hospital = dm.code " +
|
|
|
" LEFT JOIN base_org a on o.hospital = a.code " +
|
|
|
" WHERE " +
|
|
|
" (o.patient = '{patient}' " +
|
|
|
// "or o.proxy_patient = '{patient}'" +
|
|
|
") " +
|
|
|
" (o.patient = '{patient}') " +
|
|
|
" AND (o.`status` = {status} or -100 = {status})" +
|
|
|
" group by o.id " +
|
|
|
" ORDER BY o.create_time desc" +
|
|
@ -1299,7 +1286,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
|
|
|
" ( wlyy_door_service_order o " +
|
|
|
" LEFT JOIN wlyy_doctor d ON o.doctor = d.`code`) " +
|
|
|
" LEFT JOIN wlyy_door_fee_detail de on o.id = de.order_id " +
|
|
|
" LEFT JOIN dm_hospital dm on o.hospital = dm.code " +
|
|
|
" LEFT JOIN base_org a on o.hospital = a.code " +
|
|
|
" WHERE " +
|
|
|
" (o.patient = '{patient}' or o.proxy_patient = '{patient}') " +
|
|
|
" AND (o.`status` = {status} or -100 = {status})";
|
|
@ -1684,7 +1671,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public JSONObject updateOrderCardInfo(String jsonData) {
|
|
|
public JSONObject updateOrderCardInfo(String jsonData) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
JSONObject jsonObjectParam;
|
|
|
|
|
@ -2199,16 +2186,15 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public JSONObject sendOrderToDoctor(String orderId, String remark, String dispatcher, String dispathcherName, String doctor, String doctorName, String doctorJobName) {
|
|
|
public JSONObject sendOrderToDoctor(
|
|
|
String orderId, String remark, String dispatcher, String dispathcherName, String doctor, String doctorName, String doctorJobName
|
|
|
) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
WlyyDoorServiceOrderDO doorServiceOrderDO = wlyyDoorServiceOrderDao.findById(orderId).orElse(null);
|
|
|
if (null == doorServiceOrderDO) {
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
String failMsg = "当前工单不存在,id:" + orderId;
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
logger.error(failMsg);
|
|
|
return result;
|
|
|
throw new Exception(failMsg);
|
|
|
}
|
|
|
|
|
|
WlyyDoorDoctorStatusDO doorDoctorStatusDO = wlyyDoorDoctorStatusDao.queryByDoctorAndStatusIn(doctor, new Integer[]{WlyyDoorDoctorStatusDO.Status.waitForSend.getType(),
|
|
@ -2217,11 +2203,8 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
|
|
|
WlyyDoorDoctorStatusDO.Status.serving.getType(),
|
|
|
});
|
|
|
if (null == doorDoctorStatusDO) {
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
String failMsg = "当前派单的医生不存在或禁止接单,doctor:" + doctor;
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
logger.error(failMsg);
|
|
|
return result;
|
|
|
throw new Exception(failMsg);
|
|
|
}
|
|
|
|
|
|
doorServiceOrderDO.setRemark(remark);
|
|
@ -2301,7 +2284,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public JSONObject transferOrder(String orderId, String remark, String dispatcher, String dispathcherName, String doctor, String doctorName, String doctorJobName) {
|
|
|
public JSONObject transferOrder(String orderId, String remark, String dispatcher, String dispathcherName, String doctor, String doctorName, String doctorJobName) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
WlyyDoorServiceOrderDO doorServiceOrderDO = wlyyDoorServiceOrderDao.findById(orderId).orElse(null);
|
|
|
if (null == doorServiceOrderDO) {
|
|
@ -2496,31 +2479,34 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
|
|
|
* @param content
|
|
|
* @return
|
|
|
*/
|
|
|
public int qucikSendIM(String orderId, String sendId, String sendName, String contentType, String content) {
|
|
|
public int qucikSendIM(String orderId, String sendId, String sendName, String contentType, String content) throws Exception {
|
|
|
int result = -1;
|
|
|
ConsultDo consult = consultDao.queryByRelationCode(orderId);
|
|
|
if (null == consult) {
|
|
|
logger.error("当前工单未关联咨询,工单id:" + orderId);
|
|
|
System.out.println("当前工单未关联咨询,工单id:" + orderId);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
WlyyDoorServiceOrderDO wlyyDoorServiceOrder = null;
|
|
|
String response = null;
|
|
|
|
|
|
if (StringUtils.isBlank(sendId)) {
|
|
|
wlyyDoorServiceOrder = wlyyDoorServiceOrderDao.findById(orderId).orElse(null);
|
|
|
String sender = "system";
|
|
|
if (StringUtils.isNoneBlank(wlyyDoorServiceOrder.getDispatcher())) {
|
|
|
sender = wlyyDoorServiceOrder.getDispatcher();
|
|
|
try {
|
|
|
String response = null;
|
|
|
if (StringUtils.isBlank(sendId)) {
|
|
|
WlyyDoorServiceOrderDO wlyyDoorServiceOrder = wlyyDoorServiceOrderDao.findById(orderId).orElse(null);
|
|
|
String sender = "system";
|
|
|
if (StringUtils.isNoneBlank(wlyyDoorServiceOrder.getDispatcher())) {
|
|
|
sender = wlyyDoorServiceOrder.getDispatcher();
|
|
|
}
|
|
|
response = imUtill.sendTopicIM(sender, "智能助手", consult.getCode(), contentType, content, null);
|
|
|
} else {
|
|
|
response = imUtill.sendTopicIM(sendId, sendName, consult.getCode(), contentType, content, null);
|
|
|
}
|
|
|
response = imUtill.sendTopicIM(sender, "智能助手", consult.getCode(), contentType, content, null);
|
|
|
} else {
|
|
|
response = imUtill.sendTopicIM(sendId, sendName, consult.getCode(), contentType, content, null);
|
|
|
}
|
|
|
JSONObject resObj = JSONObject.parseObject(response);
|
|
|
if (resObj.getIntValue("status") == -1) {
|
|
|
logger.error("上门服务工单消息发送失败:" + resObj.getString("message"));
|
|
|
return result;
|
|
|
JSONObject resObj = JSONObject.parseObject(response);
|
|
|
if (resObj.getIntValue("status") == -1) {
|
|
|
String msg = "上门服务工单消息发送失败:" + resObj.getString("message");
|
|
|
System.out.println(msg);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
System.out.println("上门服务工单消息发送失败:" + e.getMessage());
|
|
|
return -1;
|
|
|
}
|
|
|
result = 1;
|
|
|
return result;
|
|
@ -2578,7 +2564,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
|
|
|
* @param commitPrescriptionCode
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public JSONObject createPrescription(String orderId, String prescriptionCode, String commitPrescriptionCode) {
|
|
|
public JSONObject createPrescription(String orderId, String prescriptionCode, String commitPrescriptionCode) throws Exception {
|
|
|
JSONObject res = new JSONObject();
|
|
|
//上门后在线开方,手动关联处方号的话更新处方单号跟状态
|
|
|
if (StringUtils.isNotBlank(commitPrescriptionCode)) {
|