Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

LAPTOP-KB9HII50\70708 1 year ago
parent
commit
fb00b7276d

+ 7 - 3
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/consult/service/ConsultTeamService.java

@ -217,7 +217,6 @@ public class ConsultTeamService extends ConsultService {
        consultTeam.setEvaluate(0);
        consultTeam.setDoctorRead(1); // 医生未读数量为1
        consult.setRelationCode(doorServiceOrderDO.getId());//关联业务code
//        consultTeam.setConsult(consult.getCode()); // 设置咨询标识
        consultTeam.setConsult(consult.getId()); // 设置咨询标识
        //原本:(im创建咨询) 上门服务咨询的sessionid为居民code+咨询code+工单编号+咨询类型
@ -227,7 +226,13 @@ public class ConsultTeamService extends ConsultService {
        JSONObject participants = new JSONObject();
        participants.put(patient, 0);
        String content = doorServiceOrderDO.getDoctorName() + "为您服务";
        String content;
        if (StringUtils.isNotBlank(doorServiceOrderDO.getDoctorName())) {
            content = doorServiceOrderDO.getDoctorName() + "-为您服务";
        } else {
            content = "调度员即将分配人员为您服务";
        }
        //封装JSONObject的messages
        JSONObject messages = imUtill.getCreateTopicMessage(patient, patientDO.getName(), consult.getTitle(), content, consult.getImages(), "");
        /**
@ -2175,7 +2180,6 @@ public class ConsultTeamService extends ConsultService {
//    public int cancel(String consult) {
//        return consultTeamDao.cancel(consult);
//    }
    public ConsultTeamDo findByCode(String code) {
        return consultTeamDao.findByConsult(code);
    }

+ 9 - 2
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/controller/DoorOrderController.java

@ -477,14 +477,21 @@ public class DoorOrderController extends EnvelopRestEndpoint {
        }
    }
    /**
     * 参数:
     * orderId
     * reason
     * loginUserCode
     */
    @PostMapping("refuse")
    @ApiOperation(value = "拒单")
    public Envelop refuseOrder(
            @ApiParam(value = "工单id", name = "orderId", required = true) @RequestParam(value = "orderId", required = true) String orderId,
            @ApiParam(value = "拒绝原因", name = "reason", required = false) @RequestParam(value = "reason", required = false) String reason
            @ApiParam(value = "拒绝原因", name = "reason", required = false) @RequestParam(value = "reason", required = false) String reason,
            @ApiParam(value = "登录者", name = "loginUserCode", required = false) @RequestParam(value = "loginUserCode", required = false) String loginUserCode
    ) {
        try {
            doorOrderService.refuseOrder(getUID(), orderId, reason);
            doorOrderService.refuseOrder(loginUserCode, orderId, reason);
            return success("操作成功");
        } catch (Exception e) {
            return failed(e.getMessage());

+ 61 - 65
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/service/DoorOrderService.java

@ -12,6 +12,7 @@ import com.yihu.jw.entity.base.system.SystemDictDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.door.*;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.wechat.WechatTemplateConfig;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.hospital.module.door.dao.*;
import com.yihu.jw.hospital.task.PushMsgTask;
@ -19,6 +20,7 @@ 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.order.dao.ConsultTeamOrderDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
@ -129,6 +131,9 @@ public class DoorOrderService {
    @Autowired
    WeiXinAccessTokenUtils tokenUtils;
    @Autowired
    BasePatientDao basePatientDao;
//    @Autowired
//    private SignFamilyDao signFamilyDao;
//    @Autowired
@ -663,10 +668,6 @@ public class DoorOrderService {
    /**
     * 拒单
     *
     * @param orderId
     * @param reason
     * @throws Exception
     */
    public void refuseOrder(String receiver, String orderId, String reason) throws Exception {
        WlyyDoorServiceOrderDO doorServiceOrder = doorServiceOrderDao.findOne(orderId);
@ -678,16 +679,18 @@ public class DoorOrderService {
//            this.createMessage(doorServiceOrder.getId(), "system", doorServiceOrder.getProxyPatient(), 403, "代预约服务工单重新派单", doorServiceOrder.getPatientName() + "的代预约服务工单需重新派单,请您前往处理");
            //2021-12-29 代预约医生拒单直接取消
            doorServiceOrder.setStatus(WlyyDoorServiceOrderDO.Status.cancel.getType());
            doorServiceOrder.setCancelReason(reason);   // 拒绝原因
            doorServiceOrder.setCancelReason(reason);// 拒绝原因
            doorServiceOrder.setCancelTime(new Date());
            doorServiceOrderDao.save(doorServiceOrder);
        } else {
            //删除消息
            this.systemMessageDao.orderMessageDel(doorServiceOrder.getDoctor(), orderId);
            //有调度员
            if (StringUtils.isNotBlank(doorServiceOrder.getDispatcher())) {
                // 派单消息
                this.createMessage(doorServiceOrder.getId(), "system", doorServiceOrder.getDispatcher(), 404, "服务工单拒单待重新派单", doorServiceOrder.getDoctorName() + "拒绝了" + doorServiceOrder.getProxyPatientName() + "的服务预约申请,请重新派单");
                //  调度员-派单-实时工单消息:435 医生拒单-- 王五拒绝了服务工单12345678
                // 调度员-派单-实时工单消息:435 医生拒单-- 王五拒绝了服务工单12345678
                List<SystemMessageDO> messages = systemMessageDao.queryByRelationCodeAndTypeIn(orderId, new String[]{"431", "433"});
                if (CollectionUtils.isEmpty(messages)) {
                    logger.error("当前工单没有医生待接单消息!orderId:" + orderId);
@ -713,11 +716,6 @@ public class DoorOrderService {
    /**
     * 添加【工单派单,转单】等系统消息
     *
     * @param orderId
     * @param sender
     * @param receiver
     * @param Content
     */
    public void createMessage(String orderId, String sender, String receiver, int type, String title, String Content) {
        SystemMessageDO message = new SystemMessageDO();
@ -1353,28 +1351,29 @@ public class DoorOrderService {
        // 获取微信模板 smfwdwk-上门服务待付款
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        try {
            WxTemplateConfigDO templateConfig = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndScene("xm_test_ihealth_wx", "template_process_feedback", "fwyspf");
            String first = templateConfig.getFirst();
            first = first.replace("key1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm"));
            first = first.replace("key2", null != one.getDoctorName() ? one.getDoctorName() : "");
            org.json.JSONObject json = new org.json.JSONObject();
            json.put("first", first);
            json.put("keyword1", DateUtil.dateToStrShort(new Date()));
            json.put("keyword2", "服务医生评分");
            json.put("url", templateConfig.getUrl());
            json.put("remark", templateConfig.getRemark());
            json.put("id", orderId);
            //json.put("consult",consult.getCode());
            WlyyDoorCommentDO wlyyDoorCommentDO = this.doorCommentDao.selectCommentDoctor(patient.getId(), orderId);
            String finish = "";
            if (wlyyDoorCommentDO != null) {
                finish = "0";
                json.put("finish", finish);
            } else {
                finish = "1";
                json.put("finish", finish);
            }
            pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 31, patient.getOpenid(), patient.getName(), json);
//            //暂时没有微信模板消息的功能
//            WxTemplateConfigDO templateConfig = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndScene("xm_test_ihealth_wx", "template_process_feedback", "fwyspf");
//            String first = templateConfig.getFirst();
//            first = first.replace("key1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm"));
//            first = first.replace("key2", null != one.getDoctorName() ? one.getDoctorName() : "");
//            org.json.JSONObject json = new org.json.JSONObject();
//            json.put("first", first);
//            json.put("keyword1", DateUtil.dateToStrShort(new Date()));
//            json.put("keyword2", "服务医生评分");
//            json.put("url", templateConfig.getUrl());
//            json.put("remark", templateConfig.getRemark());
//            json.put("id", orderId);
//            //json.put("consult",consult.getCode());
//            WlyyDoorCommentDO wlyyDoorCommentDO = this.doorCommentDao.selectCommentDoctor(patient.getId(), orderId);
//            String finish = "";
//            if (wlyyDoorCommentDO != null) {
//                finish = "0";
//                json.put("finish", finish);
//            } else {
//                finish = "1";
//                json.put("finish", finish);
//            }
//            pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 31, patient.getOpenid(), patient.getName(), json);
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
@ -1480,10 +1479,8 @@ public class DoorOrderService {
    /**
     * 修改预计到达时间
     *
     * @param orderId
     * @param arrivingTime
     * @return
     * orderId
     * arrivingTime
     */
    public WlyyDoorServiceOrderDO updateArrivingTime(String orderId, String arrivingTime) {
        WlyyDoorServiceOrderDO one = doorServiceOrderDao.findOne(orderId);
@ -1762,27 +1759,26 @@ public class DoorOrderService {
        return typeValues;
    }
//    /**
//     * 修改保存服务项
//     *
//     * @param jsonData
//     */
//    @org.springframework.transaction.annotation.Transactional(rollbackFor = Exception.class)
//    public void updatePackageItemInfo(String jsonData) {
//        JSONObject jsonObjectParam = JSONObject.parseObject(jsonData);
//        String orderId = String.valueOf(jsonObjectParam.get("orderId"));
//        WlyyDoorServiceOrderDO order = doorServiceOrderDao.findById(orderId);
//        // 删除出诊医生或服务项
//        wlyyDoorServiceOrderService.orderWithFeeDelete(jsonObjectParam, order);
//        // 更新服务包信息
//        wlyyDoorServiceOrderService.orderWithPackageItemFeeAdd(new JSONObject(), jsonObjectParam, order);
//
//        // 发送微信模板消息,通知居民服务项目已经变更(smyyyjjd-服务项目变更通知)
//        BasePatientDO patient = patientService.findByCode(order.getProxyPatient());
//        ConsultDo consult = consultDao.queryByRelationCode(orderId);
//        Integer status = 0;
//        try {
//
    /**
     * 修改保存服务项
     *
     * @param jsonData
     */
    @org.springframework.transaction.annotation.Transactional(rollbackFor = Exception.class)
    public void updatePackageItemInfo(String jsonData) throws Exception {
        JSONObject jsonObjectParam = JSONObject.parseObject(jsonData);
        String orderId = String.valueOf(jsonObjectParam.get("orderId"));
        WlyyDoorServiceOrderDO order = doorServiceOrderDao.findOne(orderId);
        // 删除出诊医生或服务项
        wlyyDoorServiceOrderService.orderWithFeeDelete(jsonObjectParam, order);
        // 更新服务包信息
        wlyyDoorServiceOrderService.orderWithPackageItemFeeAdd(new JSONObject(), jsonObjectParam, order);
        // 发送微信模板消息,通知居民服务项目已经变更(smyyyjjd-服务项目变更通知)
        BasePatientDO patient = basePatientDao.findOne(order.getProxyPatient());
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        Integer status = 0;
        try {
//            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback", "fwxmbgtz");
//            String first = templateConfig.getFirst();
//            first = first.replace("key1", (patient.getName() == null ? "" : patient.getName()));
@ -1794,14 +1790,14 @@ public class DoorOrderService {
//            json.put("keyword2", "服务项目变更确认");
//            json.put("url", templateConfig.getUrl());
//            json.put("remark", templateConfig.getRemark());
//            json.put("consult", consult.getCode());
//            json.put("consult", consult.getId());
//            json.put("status", status);
////            pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 32, patient.getOpenid(), patient.getName(), json);
//        } catch (Exception e) {
//            logger.error(e.getMessage());
//        }
//
//    }
//            pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 32, patient.getOpenid(), patient.getName(), json);
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
    }
    /**
     * 获取管理员端上门服务菜单分类

+ 63 - 48
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/service/WlyyDoorServiceOrderService.java

@ -673,17 +673,23 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        orderDO.setCreateUserName(orderDO.getProxyPatientName());
        orderDO.setOrderInfo("0");//工单详情 0-未推送 1-未确认 2-已确认
        //服务后收费标识(1是0否)
        if ("1".equals(orderDO.getFeeAfter())) {
            //工单状态:-1-已取消,1-待(调度员)派单,2-待(医生)接单,3-待服务,4-待付款,5-待评价,6-已完成
            if (StringUtils.isNotBlank(orderDO.getDoctor())) {
                //有医生
                orderDO.setStatus(2);//待接单(医生)
            } else {
                orderDO.setStatus(1);//待派单(调度员)
            }
//        //服务后收费标识(1是0否)
//        if ("1".equals(orderDO.getFeeAfter())) {
//            //工单状态:-1-已取消,1-待(调度员)派单,2-待(医生)接单,3-待服务,4-待付款,5-待评价,6-已完成
//            if (StringUtils.isNotBlank(orderDO.getDoctor())) {
//                orderDO.setStatus(2);//待接单(医生)
//            } else {
//                orderDO.setStatus(1);//待派单(调度员)
//            }
//        } else {
//            orderDO.setStatus(4);//待付款
//        }
        if (StringUtils.isNotBlank(orderDO.getDoctor())) {
            orderDO.setStatus(2);//待接单(医生)
        } else {
            orderDO.setStatus(4);//待付款
            orderDO.setStatus(1);//待派单(调度员)
        }
@ -709,7 +715,6 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
            throw new Exception(failMsg);
        }
        orderDO.setHospital(jsonObjectParam.getJSONObject("hospital").get("code").toString());
        orderDO.setCreateTime(new Date());
        //判断创建上门服务类型,发起类型(1本人发起 2家人待预约 3医生代预约)
@ -727,7 +732,10 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
            return result;
        }
        //发起支付订单
        /**
         * 1、发起支付订单
         * 2、发送咨询消息
         */
        result = submitDoorOrderAndSendMsg(orderDO, "5", jsonObjectParam);
        return result;
@ -739,6 +747,8 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
     * 1.直接付款走流程
     * 2.创建订单没付完款-待付款
     * 3.还要超时订单
     * -----
     * 这个上门服务是线下收费,不用在线支付
     */
    private JSONObject submitDoorOrderAndSendMsg(WlyyDoorServiceOrderDO orderDO, String type, JSONObject jsonObjectParam) throws Exception {
        boolean flag = true;
@ -771,44 +781,53 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
            businessOrderDO.setLastPayTime(lastPayTime);
        } else {
            /**
             * 是否付款完成
             * 判断付款时间是否超过时长了--还需要定时任务监听订单修改状态,把未付款改成已取消
             */
            if (businessOrderDO.getStatus() != 1) {
                long nowTime = System.currentTimeMillis();
                Long lastPayTime = businessOrderDO.getLastPayTime();
                if (lastPayTime > nowTime) {
                    //超时了 修改工单状态成已取消
                    orderDO.setStatus(-1);//-已取消
                    wlyyDoorServiceOrderDao.save(orderDO);//更新上门工单
                    businessOrderDO.setStatus(2);//已取消
                    businessOrderDao.save(businessOrderDO);//更新业务表
                    flag = false;//不用创建咨询内容
                }
            }
        }
        //费用0时无需支付
        if ("4".equals(type) && 0.0 == orderDO.getTotalFee().doubleValue()) {
            businessOrderDO.setStatus(1);//1已支付
            businessOrderDao.save(businessOrderDO);
        } else {
            /**
             * 保存订单信息-这边要判断付款回调修改状态值-付款失败取消订单
             * businessOrderService
             * 暂时没用,线下付款的
             * 1、是否付款完成
             * 2、判断付款时间是否超过时长了--还需要定时任务监听订单修改状态,把未付款改成已取消
             */
            businessOrderDO.setStatus(0);//0待支付
            businessOrderDao.save(businessOrderDO);
//            if (businessOrderDO.getStatus() != 1) {
//                long nowTime = System.currentTimeMillis();
//                Long lastPayTime = businessOrderDO.getLastPayTime();
//                if (lastPayTime > nowTime) {
//                    //超时了 修改工单状态成已取消
//                    orderDO.setStatus(-1);//-已取消
//                    wlyyDoorServiceOrderDao.save(orderDO);//更新上门工单
//                    businessOrderDO.setStatus(2);//已取消
//                    businessOrderDao.save(businessOrderDO);//更新业务表
//                    flag = false;//不用创建咨询内容
//                }
//            }
        }
        /**
         *  todo 调用微信支付
         *  再来更新flag标识
         *  1、费用0时无需支付
         *  2、调用微信支付 再来更新flag标识
         */
//        if ("5".equals(type) && 0.0 == orderDO.getTotalFee().doubleValue()) {
//            businessOrderDO.setStatus(1);//1已支付
//            businessOrderDao.save(businessOrderDO);
//        } else {
//            /**
//             * 保存订单信息-这边要判断付款回调修改状态值-付款失败取消订单
//             * businessOrderService
//             */
//            businessOrderDO.setStatus(0);//0待支付
//            businessOrderDao.save(businessOrderDO);
//        }
        //给出标识是否成功,往下面创建咨询信息发送内容
        //保存业务表
        businessOrderDao.save(businessOrderDO);
        /**
         * 目前是线下付款的
         * 给出标识是否成功,往下面创建咨询信息发送内容
         */
        if (flag) {
            //获取机构的调度员
            List<Map<String, Object>> dispatcherList = queryDispatcherInfoByPatient(jsonObjectParam.getJSONObject("hospital").get("code").toString());
            //支付成功或者不用支付
            //创建咨询
            JSONObject successOrNot = consultTeamService.addDoorServiceConsult(orderDO.getId());
@ -831,8 +850,6 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
                result.put(ResponseContant.resultMsg, consultTeam);
                return result;
            }
            //获取机构的调度员
            List<Map<String, Object>> dispatcherList = queryDispatcherInfoByPatient(jsonObjectParam.getJSONObject("hospital").get("code").toString());
            //有调度员
            if (!dispatcherList.isEmpty()) {
@ -873,8 +890,6 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
            orderDO.setStatus(-1);//-已取消
            wlyyDoorServiceOrderDao.save(orderDO);//更新上门工单
        }
        //result赋值返回
        return result;
    }
@ -3063,8 +3078,8 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
    public List<Map<String, Object>> getDotorOrgList() {
        String sql = "SELECT a.org_code 'hospitalCode',a.org_name 'hospitalName' \n" +
                "FROM base_doctor_hospital a INNER JOIN base_doctor b\n" +
                "WHERE b.doctor_level='1'\n" +
                "GROUP BY a.org_code,a.org_name ";
                "WHERE b.doctor_level='1'\n";
        sql += " GROUP BY a.org_code,a.org_name ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }