suqinyi пре 1 година
родитељ
комит
23650e8ded

+ 120 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/controller/PatientDoorServiceApplicationController.java

@ -0,0 +1,120 @@
package com.yihu.jw.hospital.module.door.controller;
import com.yihu.jw.entity.door.WlyyDoorServiceApplicationDo;
import com.yihu.jw.hospital.module.door.service.DoorServiceApplicationService;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by zdm on 2019/3/13.
 */
@RestController
@RequestMapping(value = "/patient/onsiteService", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "居民端-思明区上门服务")
public class PatientDoorServiceApplicationController extends EnvelopRestEndpoint {
    @Autowired
    private DoorServiceApplicationService doorServiceApplicationService;
    @RequestMapping(value = "findPatientOnsiteService", method = RequestMethod.GET)
    @ApiOperation(value = "首页获取居民上门服务开通状况及取消预约次数")
    public String findPatientOnsiteService(
            @ApiParam(name = "patientCode", value = "当前居民code")
            @RequestParam(value = "patientCode", required = false) String patientCode) {
        try {
            if (StringUtils.isBlank(patientCode)) {
                patientCode = getRepUID();
            }
            JSONObject jsonObject = doorServiceApplicationService.findPatientOnsiteService(patientCode);
            return write(200, "获取成功", "data", jsonObject);
        } catch (Exception ex) {
            return error(-1, "获取失败!" + ex.getMessage());
        }
    }
//    @RequestMapping(value = "getPatientFamilyMembersInfo", method = RequestMethod.GET)
//    @ApiOperation(value = "获取当前居民家庭成员信息")
//    public String getPatientFamilyMembersInfo(
//            @ApiParam(name = "patientCode", value = "当前居民code")
//            @RequestParam(value = "patientCode",required = false)String patientCode){
//        try {
//            if(StringUtils.isBlank(patientCode)){
//                patientCode=getLastUid();
//            }
//            JSONArray jsonArray= doorServiceApplicationService.getPatientFamilyMembers(patientCode);
//            return write(200, "获取成功", "data", jsonArray);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return error(-1, "获取失败!"+e.getMessage());
//        }
//    }
    @RequestMapping(value = "create", method = RequestMethod.POST)
    @ApiOperation(value = "开通服务资格")
    public String create(
            @ApiParam(name = "jsonData", value = "开通服务资格内容jsonData")
            @RequestParam(value = "jsonData", required = true) String jsonData,
            @ApiParam(name = "patientCode", value = "patientCode")
            @RequestParam(value = "patientCode", required = false) String patientCode) {
        try {
            if (StringUtils.isBlank(patientCode)) {
                patientCode = getRepUID();
            }
            WlyyDoorServiceApplicationDo wlyyDoorServiceApplicationDo = doorServiceApplicationService.create("1", jsonData, patientCode);
            return write(200, "获取成功", "data", wlyyDoorServiceApplicationDo);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "获取失败!" + e.getMessage());
        }
    }
    @RequestMapping(value = "update", method = RequestMethod.POST)
    @ApiOperation(value = "变更开通服务资格")
    public String update(
            @ApiParam(name = "jsonData", value = "开通服务资格内容jsonData")
            @RequestParam(value = "jsonData", required = true) String jsonData,
            @ApiParam(name = "patientCode", value = "patientCode")
            @RequestParam(value = "patientCode", required = false) String patientCode) {
        try {
            if (StringUtils.isBlank(patientCode)) {
                patientCode = getRepUID();
            }
            WlyyDoorServiceApplicationDo wlyyDoorServiceApplicationDo = doorServiceApplicationService.update(jsonData, patientCode);
            return write(200, "获取成功", "data", wlyyDoorServiceApplicationDo);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "获取失败!" + e.getMessage());
        }
    }
    @RequestMapping(value = "findPatientOnsiteServiceStatus", method = RequestMethod.GET)
    @ApiOperation(value = "获取居民审核状态: -1删除,0审核中,1未通过,2审核通过,3已过期")
    public String findPatientOnsiteServiceStatus(
            @ApiParam(name = "patientCode", value = "当前居民code")
            @RequestParam(value = "patientCode", required = false) String patientCode) {
        try {
            if (StringUtils.isBlank(patientCode)) {
                patientCode = getRepUID();
            }
            Integer status = doorServiceApplicationService.findOnsiteServiceStatusByPatient(patientCode);
            return write(200, "获取成功", "data", status);
        } catch (Exception ex) {
            return error(-1, "获取失败!" + ex.getMessage());
        }
    }
}

+ 64 - 46
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/controller/WlyyDoorServiceOrderController.java

@ -67,6 +67,45 @@ public class WlyyDoorServiceOrderController extends EnvelopRestEndpoint {
        }
    }
    /**
     * 居民端 上门服务预约工单的状态分组统计数量
     */
    @GetMapping(value = "queryInfoStatusCountList")
    @ApiOperation(value = "统计上门服务工单各状态下的数量列表")
    public Envelop queryInfoStatusCountList(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = false) String patient) {
        JSONObject result = wlyyDoorServiceOrderService.queryInfoStatusCountList(patient);
        if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
            return failed(result.getString(ResponseContant.resultMsg));
        }
        return success(result.get(ResponseContant.resultMsg));
    }
    @GetMapping(value = "infoList")
    @ApiOperation(value = "查询预约咨询记录列表")
    public PageEnvelop page(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient,
            @ApiParam(name = "status", value = "工单状态,状态为全部时不传") @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1") @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15") @RequestParam(value = "size") int size
    ) {
        JSONObject result = wlyyDoorServiceOrderService.queryInfoList(patient, status, page, size);
        if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
            return PageEnvelop.getError(result.getString(ResponseContant.resultMsg), -1);
        }
        int count = result.getIntValue(ResponseContant.count);
        return success((List) result.get(ResponseContant.resultMsg), count, page, size);
    }
    @GetMapping(value = "queryOne")
    @ApiOperation(value = "查询单个咨询工单详情")
    public ObjEnvelop queryOneDetail(
            @ApiParam(name = "id", value = "工单id") @RequestParam(value = "id", required = true) String id) {
        return success(wlyyDoorServiceOrderService.queryOneDetail(id));
    }
    @PostMapping(value = "qucikSendIM")
    @ApiOperation(value = "通过IM向客户端推送消息")
@ -77,13 +116,13 @@ public class WlyyDoorServiceOrderController extends EnvelopRestEndpoint {
            @ApiParam(name = "contentType", value = "消息内容类型:1-文本信息,19-服务工单格式化消息", required = true) @RequestParam String contentType,
            @ApiParam(name = "content", value = "消息内容json", required = true) @RequestParam String content
    ) {
        int result = wlyyDoorServiceOrderService.qucikSendIM(orderId, sendId, sendName, contentType, content);
        if (result == -1) {
            return failed("发送失败!");
        try {
            int result = wlyyDoorServiceOrderService.qucikSendIM(orderId, sendId, sendName, contentType, content);
            return success("发送成功");
        } catch (Exception e) {
            e.printStackTrace();
            return failed("发送失败! " + e.getMessage());
        }
        return success("发送成功");
    }
@ -109,40 +148,20 @@ public class WlyyDoorServiceOrderController extends EnvelopRestEndpoint {
    @GetMapping(value = "queryDispatcherInfoByPatient")
    @ApiOperation(value = "获取居民所签约的机构的调度员信息")
    public Envelop queryDispatcherInfoByPatient(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient) {
        JSONObject result = wlyyDoorServiceOrderService.queryDispatcherInfoByPatient(patient);
        if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
            return failed(result.getString(ResponseContant.resultMsg));
            @ApiParam(name = "hospitalCode", value = "机构code") @RequestParam(value = "hospitalCode", required = true) String hospitalCode) {
        try {
            List<Map<String, Object>> list = wlyyDoorServiceOrderService.queryDispatcherInfoByPatient(hospitalCode);
            return success("查询成功", list);
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
        }
        int count = result.getIntValue(ResponseContant.count);
        return success(result.get(ResponseContant.resultMsg));
    }
    @GetMapping(value = "infoList")
    @ApiOperation(value = "查询预约咨询记录")
    public PageEnvelop page(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient,
            @ApiParam(name = "status", value = "工单状态,状态为全部时不传") @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1") @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15") @RequestParam(value = "size") int size) {
        JSONObject result = wlyyDoorServiceOrderService.queryInfoList(patient, status, page, size);
        if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
            return PageEnvelop.getError(result.getString(ResponseContant.resultMsg), -1);
        }
        int count = result.getIntValue(ResponseContant.count);
        return success((List) result.get(ResponseContant.resultMsg), count, page, size);
    }
    @GetMapping(value = "queryInfoStatusCountList")
    @ApiOperation(value = "统计上门服务工单各状态下的数量列表")
    public Envelop queryInfoStatusCountList(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = false) String patient) {
        JSONObject result = wlyyDoorServiceOrderService.queryInfoStatusCountList(patient);
        if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
            return failed(result.getString(ResponseContant.resultMsg));
        }
        return success(result.get(ResponseContant.resultMsg));
    }
    @GetMapping(value = "list")
    @ApiOperation(value = "获取列表")
@ -160,12 +179,7 @@ public class WlyyDoorServiceOrderController extends EnvelopRestEndpoint {
        return success(result);
    }
    @GetMapping(value = "queryOne")
    @ApiOperation(value = "查询单个咨询工单详情")
    public ObjEnvelop queryOneDetail(
            @ApiParam(name = "id", value = "工单id") @RequestParam(value = "id", required = true) String id) {
        return success(wlyyDoorServiceOrderService.queryOneDetail(id));
    }
    @GetMapping(value = "twoDimensionalCode")
    @ApiOperation(value = "生成二维码接口")
@ -226,11 +240,15 @@ public class WlyyDoorServiceOrderController extends EnvelopRestEndpoint {
    @ApiOperation(value = "更新预约简要信息")
    public Envelop updateOrderCardInfo(
            @ApiParam(name = "jsonData", value = "json数据") @RequestParam(value = "jsonData", required = true) String jsonData) {
        JSONObject result = wlyyDoorServiceOrderService.updateOrderCardInfo(jsonData);
        if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
            return failed(result.getString(ResponseContant.resultMsg));
        try {
            JSONObject result = wlyyDoorServiceOrderService.updateOrderCardInfo(jsonData);
            return success("更新成功", result.get(ResponseContant.resultMsg));
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
        }
        return success(result.get(ResponseContant.resultMsg));
    }
    @GetMapping(value = "queryOneConclusion")

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

@ -43,6 +43,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.transaction.Transactional;
import java.io.*;
import java.lang.Boolean;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -1619,56 +1620,59 @@ public class DoorOrderService {
    }
//    /**
//     * 根据服务项计算服务费用
//     *
//     * @param jsonData 格式[{"itemCode":"","fee":"","number":""}]
//     * @param patient  居民code
//     * @return
//     */
//    public Map<String, Object> countServerPackagePrice(String jsonData, String patient) {
//        Map<String, Object> map = new HashMap<>();
//        BigDecimal serverPackagePrice = new BigDecimal("0.00");
//        BigDecimal cashPrice = new BigDecimal("0.00");
//        //获取居民签约服务项及次数
//        SignFamily signFamily = signFamilyDao.findByPatient(patient);
//        String sql = "SELECT ip.service_item_code as itemCode, sum(ip.service_times) as times  FROM wlyy_server_package_patient pp , wlyy_server_package_item_patient ip " +
//                "where pp.`code` = ip.server_package_patient_code and  pp.patient = '" + patient + "' and pp.hospital = '" + signFamily.getHospital() + "' and pp.`status` = 1 " +
//                "GROUP BY ip.service_item_code ";
//        List<Map<String, Object>> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(String.class));
//
//        JSONArray jsonArray = JSONArray.parseArray(jsonData);
//        for (Object o : jsonArray) {
//            Boolean b = false;
//            BigDecimal times = null;
//            JSONObject jsonObject = (JSONObject) o;
//            String itemCode = jsonObject.getString("itemCode");
//            BigDecimal fee = jsonObject.getBigDecimal("fee");
//            BigDecimal number = jsonObject.getBigDecimal("number");
//            //遍历是否是居民签约的服务项,如果是,看还剩多少次数
//            for (Map<String, Object> m : list) {
//                if ((m.get(itemCode) + "").equals(itemCode)) {
//                    b = true;
//                    times = (BigDecimal) map.get("times");
//                }
//            }
//            //判断服务包里面的次数是否够抵扣,不够的仍需支付
//            if (b) {
//                if (times.compareTo(number) > -1) {
//                    serverPackagePrice = serverPackagePrice.add(fee.multiply(number));
//                } else {
//                    //还需另外支付次数
//                    BigDecimal t = number.subtract(times);
//                    cashPrice = cashPrice.add(fee.multiply(t));
//                }
//            } else {
//                cashPrice = cashPrice.add(fee.multiply(number));
//            }
//        }
//        map.put("serverPackagePrice", serverPackagePrice);
//        map.put("cashPrice", cashPrice);
//        return map;
//    }
    /**
     * 根据服务项计算服务费用
     *
     * @param jsonData 格式[{"itemCode":"","fee":"","number":""}]
     * @param patient  居民code
     * @return
     */
    public Map<String, Object> countServerPackagePrice(String jsonData, String patient) {
        Map<String, Object> map = new HashMap<>();
        BigDecimal serverPackagePrice = new BigDecimal("0.00");
        BigDecimal cashPrice = new BigDecimal("0.00");
        //获取居民签约服务项及次数
        String sql = "SELECT ip.service_item_code as itemCode, sum(ip.service_times) as times  " +
                "FROM wlyy_server_package_patient pp , wlyy_server_package_item_patient ip " +
                "where pp.`code` = ip.server_package_patient_code" +
                " and  pp.patient = '" + patient + "' " +
//                " and pp.hospital = '" + signFamily.getHospital() + "' " +
                " and pp.`status` = 1 " +
                "GROUP BY ip.service_item_code ";
        List<Map<String, Object>> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(String.class));
        JSONArray jsonArray = JSONArray.parseArray(jsonData);
        for (Object o : jsonArray) {
            Boolean b = false;
            BigDecimal times = null;
            JSONObject jsonObject = (JSONObject) o;
            String itemCode = jsonObject.getString("itemCode");
            BigDecimal fee = jsonObject.getBigDecimal("fee");
            BigDecimal number = jsonObject.getBigDecimal("number");
            //遍历是否是居民签约的服务项,如果是,看还剩多少次数
            for (Map<String, Object> m : list) {
                if ((m.get(itemCode) + "").equals(itemCode)) {
                    b = true;
                    times = (BigDecimal) map.get("times");
                }
            }
            //判断服务包里面的次数是否够抵扣,不够的仍需支付
            if (b) {
                if (times.compareTo(number) > -1) {
                    serverPackagePrice = serverPackagePrice.add(fee.multiply(number));
                } else {
                    //还需另外支付次数
                    BigDecimal t = number.subtract(times);
                    cashPrice = cashPrice.add(fee.multiply(t));
                }
            } else {
                cashPrice = cashPrice.add(fee.multiply(number));
            }
        }
        map.put("serverPackagePrice", serverPackagePrice);
        map.put("cashPrice", cashPrice);
        return map;
    }
//    /**
//     * 更新居民签约服务包服务项次数

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

@ -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)) {