|  | @ -0,0 +1,554 @@
 | 
	
		
			
				|  |  | package com.yihu.jw.care.endpoint.doorCoach;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.yihu.jw.care.endpoint.BaseController;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.yihu.jw.care.service.doorCoach.DoctorDoorCoachOrderService;
 | 
	
		
			
				|  |  | import com.yihu.jw.care.service.doorCoach.PatientDoorCoachOrderService;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachConclusionDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.ResponseContant;
 | 
	
		
			
				|  |  | import io.swagger.annotations.Api;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import io.swagger.annotations.ApiOperation;
 | 
	
		
			
				|  |  | import io.swagger.annotations.ApiParam;
 | 
	
		
			
				|  |  | import org.apache.commons.lang.StringUtils;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.http.MediaType;
 | 
	
		
			
				|  |  | import org.springframework.jdbc.core.BeanPropertyRowMapper;
 | 
	
		
			
				|  |  | import org.springframework.web.bind.annotation.*;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import java.util.ArrayList;
 | 
	
		
			
				|  |  | import java.util.Date;
 | 
	
		
			
				|  |  | import java.util.List;
 | 
	
		
			
				|  |  | import java.util.Map;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * 上门辅导
 | 
	
		
			
				|  |  |  *
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  | @RestController
 | 
	
		
			
				|  |  | @RequestMapping(value = "/doctor/doorCoach/serviceOrder", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
 | 
	
		
			
				|  |  | @Api(description = "医生端-上门辅导")
 | 
	
		
			
				|  |  | public class DoctorDoorCoachOrderController extends BaseController {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PatientDoorCoachOrderService patientDoorCoachOrderService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private DoctorDoorCoachOrderService doctorDoorCoachOrderService;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @PostMapping(value = "proxyCreate")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "创建上门服务咨询--医生代预约")
 | 
	
		
			
				|  |  |     public String create(@ApiParam(name = "jsonData", value = "Json数据", required = true) @RequestParam String jsonData) {
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  |             JSONObject result = patientDoorCoachOrderService.proxyCreate(jsonData,getUID());
 | 
	
		
			
				|  |  |             if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
 | 
	
		
			
				|  |  |                 return error(-1, result.getString(ResponseContant.resultMsg));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             return write(200, "提交成功!","orderId",result.getString("orderId"));
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |             return error(-1, e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping("/getDoorOrderNum")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "获取医生待服务工单数量")
 | 
	
		
			
				|  |  |     public String getDoorOrderNum(
 | 
	
		
			
				|  |  |             @ApiParam(name = "doctor", value = "医生codedoctor")
 | 
	
		
			
				|  |  |             @RequestParam(value = "doctor", required = true) String doctor) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             return write(200, "获取成功", "data",doctorDoorCoachOrderService.getDoorOrderNum(doctor));
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             error(e);
 | 
	
		
			
				|  |  |             return error(-1, "获取失败!" + e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping(value = "queryDoctorListNotStopped")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "服务人员列表(可接单状态的医生列表)")
 | 
	
		
			
				|  |  |     public String queryDoctorListWithNotStopped(
 | 
	
		
			
				|  |  |             @ApiParam(name = "hospital", value = "机构code", required = true) @RequestParam(value = "hospital") String hospital,
 | 
	
		
			
				|  |  |             @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) {
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  |             JSONObject result = patientDoorCoachOrderService.queryDoctorListWithNotStopped(hospital,page, size);
 | 
	
		
			
				|  |  |             if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
 | 
	
		
			
				|  |  |                 return error(-1,result.getString(ResponseContant.resultMsg));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             int count = result.getIntValue(ResponseContant.count);
 | 
	
		
			
				|  |  |             JSONObject object = new JSONObject();
 | 
	
		
			
				|  |  |             object.put("total",count);
 | 
	
		
			
				|  |  |             object.put("detailModelList",result.get(ResponseContant.resultMsg));
 | 
	
		
			
				|  |  |             object.put("currPage",page);
 | 
	
		
			
				|  |  |             object.put("pageSize",size);
 | 
	
		
			
				|  |  |             return write(200,"查询成功","data",object);
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return error(-1,"查询失败");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @PostMapping(value = "sendOrderToDoctor")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "调度员给医生派单")
 | 
	
		
			
				|  |  |     public String sendOrderToDoctor(
 | 
	
		
			
				|  |  |             @ApiParam(name = "orderId", value = "工单id") @RequestParam(value = "orderId", required = true) String orderId,
 | 
	
		
			
				|  |  |             @ApiParam(name = "remark", value = "调度员备注") @RequestParam(value = "remark", required = false) String remark,
 | 
	
		
			
				|  |  |             @ApiParam(name = "dispatcher", value = "调度员code") @RequestParam(value = "dispatcher", required = true) String dispatcher,
 | 
	
		
			
				|  |  |             @ApiParam(name = "dispathcherName", value = "调度员姓名") @RequestParam(value = "dispathcherName", required = true) String dispathcherName,
 | 
	
		
			
				|  |  |             @ApiParam(name = "doctor", value = "医生code") @RequestParam(value = "doctor", required = true) String doctor,
 | 
	
		
			
				|  |  |             @ApiParam(name = "doctorName", value = "医生姓名") @RequestParam(value = "doctorName", required = true) String doctorName,
 | 
	
		
			
				|  |  |             @ApiParam(name = "doctorJobName", value = "医生职称") @RequestParam(value = "doctorJobName", required = false) String doctorJobName) {
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  |             JSONObject result = patientDoorCoachOrderService.sendOrderToDoctor(orderId, remark,dispatcher,dispathcherName, doctor, doctorName ,doctorJobName);
 | 
	
		
			
				|  |  |             if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
 | 
	
		
			
				|  |  |                 return error( -1,result.getString(ResponseContant.resultMsg));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             return write(200,"派单成功","data",result.get(ResponseContant.resultMsg));
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return error(-1,"派单失败");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @PostMapping(value = "transferOrder")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "医生转派单")
 | 
	
		
			
				|  |  |     public String transferOrder(
 | 
	
		
			
				|  |  |             @ApiParam(name = "orderId", value = "工单id") @RequestParam(value = "orderId", required = true) String orderId,
 | 
	
		
			
				|  |  |             @ApiParam(name = "remark", value = "当前医生备注") @RequestParam(value = "remark", required = false) String remark,
 | 
	
		
			
				|  |  |             @ApiParam(name = "dispatcher", value = "当前医生code") @RequestParam(value = "dispatcher", required = true) String dispatcher,
 | 
	
		
			
				|  |  |             @ApiParam(name = "dispathcherName", value = "当前医生姓名") @RequestParam(value = "dispathcherName", required = true) String dispathcherName,
 | 
	
		
			
				|  |  |             @ApiParam(name = "doctor", value = "医生code") @RequestParam(value = "doctor", required = true) String doctor,
 | 
	
		
			
				|  |  |             @ApiParam(name = "doctorName", value = "医生姓名") @RequestParam(value = "doctorName", required = true) String doctorName,
 | 
	
		
			
				|  |  |             @ApiParam(name = "doctorJobName", value = "医生职称") @RequestParam(value = "doctorJobName", required = false) String doctorJobName) {
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  |             JSONObject result = patientDoorCoachOrderService.transferOrder(orderId, remark,dispatcher,dispathcherName, doctor, doctorName ,doctorJobName);
 | 
	
		
			
				|  |  |             if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
 | 
	
		
			
				|  |  |                 return error( -1,result.getString(ResponseContant.resultMsg));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             return write(200,"派单成功","data",result.get(ResponseContant.resultMsg));
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |             return error(-1, "派单失败!");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @PostMapping("acceptOrder")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "接单")
 | 
	
		
			
				|  |  |     public String acceptOrder(
 | 
	
		
			
				|  |  |             @ApiParam(value = "工单id", name = "orderId", required = true) @RequestParam(value = "orderId", required = true) String orderId,
 | 
	
		
			
				|  |  |             @ApiParam(value = "医生职称code", name = "jobCode", required = false) @RequestParam(value = "jobCode", required = false) String jobCode,
 | 
	
		
			
				|  |  |             @ApiParam(value = "医生职称", name = "jobCodeName", required = false) @RequestParam(value = "jobCodeName", required = false) String jobCodeName,
 | 
	
		
			
				|  |  |             @ApiParam(value = "医院级别", name = "hospitalLevel", required = false) @RequestParam(value = "hospitalLevel",defaultValue = "4",required = false) int hospitalLevel) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             doctorDoorCoachOrderService.acceptOrder(orderId,jobCode,jobCodeName,hospitalLevel);
 | 
	
		
			
				|  |  |             return write(200, "操作成功");
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             error(e);
 | 
	
		
			
				|  |  |             return error(-1, "操作失败!" + e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @PostMapping("refuse")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "拒单")
 | 
	
		
			
				|  |  |     public String 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) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             doctorDoorCoachOrderService.refuseOrder(getUID(),orderId, reason);
 | 
	
		
			
				|  |  |             return write(200, "操作成功");
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             error(e);
 | 
	
		
			
				|  |  |             return error(-1, "操作失败!" + e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @PostMapping(value = "cancelOrder")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "取消工单")
 | 
	
		
			
				|  |  |     public String cancelOrder(
 | 
	
		
			
				|  |  |             @ApiParam(name = "orderId", value = "工单id") @RequestParam(value = "orderId", required = true) String orderId,
 | 
	
		
			
				|  |  |             @ApiParam(name = "type", value = "取消类型:1-调度员主动取消,2-居民取消, 3-医生取消") @RequestParam(value = "type", required = true) int type,
 | 
	
		
			
				|  |  |             @ApiParam(name = "reason", value = "取消理由") @RequestParam(value = "reason", required = false) String reason,
 | 
	
		
			
				|  |  |             @ApiParam(name = "dispatcher", value = "取消工单的调度员(只允许调度员来操作)") @RequestParam(value = "dispatcher", required = false) String dispatcher,
 | 
	
		
			
				|  |  |             @ApiParam(name = "dispathcherName", value = "调度员姓名") @RequestParam(value = "dispathcherName", required = false) String dispatcherName) {
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  |             JSONObject result = patientDoorCoachOrderService.cancelOrder(orderId, type, reason,dispatcher,dispatcherName);
 | 
	
		
			
				|  |  |             if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
 | 
	
		
			
				|  |  |                 return error(-1,result.getString(ResponseContant.resultMsg));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             return write(200,"取消成功","data",result.get(ResponseContant.resultMsg));
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return error(-1,"取消失败");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @PostMapping("signIn")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "上门服务签到")
 | 
	
		
			
				|  |  |     public String signIn(
 | 
	
		
			
				|  |  |             @ApiParam(value = "工单id", name = "orderId")
 | 
	
		
			
				|  |  |             @RequestParam(value = "orderId", required = true) String orderId,
 | 
	
		
			
				|  |  |             @ApiParam(value = "签到时间", name = "signTime")
 | 
	
		
			
				|  |  |             @RequestParam(value = "signTime", required = false) String signTime,
 | 
	
		
			
				|  |  |             @ApiParam(value = "签到方式:1-定位,2-扫码,3-拍照,4-二维码", name = "signWay")
 | 
	
		
			
				|  |  |             @RequestParam(value = "signWay", required = false) Integer signWay,
 | 
	
		
			
				|  |  |             @ApiParam(value = "签到地址", name = "signLocation")
 | 
	
		
			
				|  |  |             @RequestParam(value = "signLocation", required = false) String signLocation,
 | 
	
		
			
				|  |  |             @ApiParam(value = "签到照片", name = "signImg")
 | 
	
		
			
				|  |  |             @RequestParam(value = "signImg", required = false) String signImg,
 | 
	
		
			
				|  |  |             @ApiParam(value = "二维码内容", name = "twoDimensionalCode")
 | 
	
		
			
				|  |  |             @RequestParam(value = "twoDimensionalCode", required = false) String twoDimensionalCode) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             BaseDoorCoachOrderDO baseDoorCoachOrderDO = doctorDoorCoachOrderService.signIn(orderId, signTime, signWay, signLocation, signImg,twoDimensionalCode,getUID());
 | 
	
		
			
				|  |  |             if (baseDoorCoachOrderDO != null){
 | 
	
		
			
				|  |  |                 return write(200, "操作成功", "data", baseDoorCoachOrderDO);
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 return error(-1,"扫码签到失败");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             error(e);
 | 
	
		
			
				|  |  |             return error(-1, "操作失败!" + e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @PostMapping("updateDoorConclusion")
 | 
	
		
			
				|  |  |     @ApiOperation("编辑保存服务工单小结")
 | 
	
		
			
				|  |  |     public String updateDoorConclusion(
 | 
	
		
			
				|  |  |             @ApiParam(value = "工单id", name = "orderId",required = true)
 | 
	
		
			
				|  |  |             @RequestParam(value = "orderId", required = true) String orderId,
 | 
	
		
			
				|  |  |             @ApiParam(value = "服务附件,至少一张,至多3张", name = "conclusionImg",required = false)
 | 
	
		
			
				|  |  |             @RequestParam(value = "conclusionImg", required = false) String conclusionImg,
 | 
	
		
			
				|  |  |             @ApiParam(value = "服务小结", name = "conclusion",required = false)
 | 
	
		
			
				|  |  |             @RequestParam(value = "conclusion", required = false) String conclusion,
 | 
	
		
			
				|  |  |             @ApiParam(value = "服务小结是否登记,1跳过登记;2-登记", name = "conclusionStatus")
 | 
	
		
			
				|  |  |             @RequestParam(value = "conclusionStatus", required = false,defaultValue = "2") Integer conclusionStatus) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             BaseDoorCoachConclusionDO doorConclusion = doctorDoorCoachOrderService.updateDoorConclusion(orderId,conclusion,conclusionImg,conclusionStatus);
 | 
	
		
			
				|  |  |             return write(200, "保存成功", "data", doorConclusion);
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             error(e);
 | 
	
		
			
				|  |  |             return error(-1, "保存失败!" + e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping("getDoorConclusion")
 | 
	
		
			
				|  |  |     @ApiOperation("获取服务工单小结")
 | 
	
		
			
				|  |  |     public String getDoorConclusion(
 | 
	
		
			
				|  |  |             @ApiParam(value = "医生code", name = "doctor")
 | 
	
		
			
				|  |  |             @RequestParam(value = "doctor", required = false) String doctor,
 | 
	
		
			
				|  |  |             @ApiParam(value = "工单id", name = "orderId")
 | 
	
		
			
				|  |  |             @RequestParam(value = "orderId", required = false) String orderId) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             // 没有提供工单id的情况下,默认代入上一次服务信息记录
 | 
	
		
			
				|  |  |             if (StringUtils.isEmpty(orderId)) {
 | 
	
		
			
				|  |  |                 orderId = doctorDoorCoachOrderService.getOrderIdByDoctor(doctor);
 | 
	
		
			
				|  |  |                 if (StringUtils.isEmpty(orderId)) {
 | 
	
		
			
				|  |  |                     return error(204, "获取失败,该医生暂无工单" );
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             // 根据orderId查询工单小结表
 | 
	
		
			
				|  |  |             BaseDoorCoachConclusionDO doorConclusion = doctorDoorCoachOrderService.getDoorConclusion(orderId);
 | 
	
		
			
				|  |  |             return write(200, "获取成功", "data", doorConclusion);
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             error(e);
 | 
	
		
			
				|  |  |             return error(-1, "获取失败!" + e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @PostMapping("saveOrderFinishByDoctor")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "确认完成工单")
 | 
	
		
			
				|  |  |     public String saveOrderFinishByDoctor(
 | 
	
		
			
				|  |  |             @ApiParam(value = "工单id", name = "orderId")
 | 
	
		
			
				|  |  |             @RequestParam(value = "orderId", required = true) String orderId,
 | 
	
		
			
				|  |  |             @ApiParam(value = "确认结束服务方式 1-电子签名,2-手持身份证拍照", name = "finishWay")
 | 
	
		
			
				|  |  |             @RequestParam(value = "finishWay", required = false) Integer finishWay,
 | 
	
		
			
				|  |  |             @ApiParam(value = "确认结束服务照片", name = "finishImg")
 | 
	
		
			
				|  |  |             @RequestParam(value = "finishImg", required = false) String finishImg) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             return write(200, "获取成功", "data", doctorDoorCoachOrderService.saveOrderFinishByDoctor(orderId, finishWay, finishImg));
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             error(e);
 | 
	
		
			
				|  |  |             return error(-1, "获取失败!" + e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @PostMapping("updateArrivingTime")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "修改预计到达时间")
 | 
	
		
			
				|  |  |     public String updateArrivingTime(
 | 
	
		
			
				|  |  |             @ApiParam(value = "工单id", name = "orderId")
 | 
	
		
			
				|  |  |             @RequestParam(value = "orderId", required = true) String orderId,
 | 
	
		
			
				|  |  |             @ApiParam(value = "医生预计到达时间", name = "arrivingTime")
 | 
	
		
			
				|  |  |             @RequestParam(value = "arrivingTime", required = true) String arrivingTime) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             BaseDoorCoachOrderDO baseDoorCoachOrderDO = doctorDoorCoachOrderService.updateArrivingTime(orderId, arrivingTime);
 | 
	
		
			
				|  |  |             return write(200, "修改成功", "data", baseDoorCoachOrderDO);
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             error(e);
 | 
	
		
			
				|  |  |             return error(-1, "修改失败!" + e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping("/topStatusBarNum")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "顶部状态栏订单分类tab")
 | 
	
		
			
				|  |  |     public String topStatusBarNum(
 | 
	
		
			
				|  |  |             @ApiParam(name = "doctor", value = "医生code")
 | 
	
		
			
				|  |  |             @RequestParam(value = "doctor", required = true) String doctor) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             Map<String, Integer> map = doctorDoorCoachOrderService.getNumGroupByStatus(doctor);
 | 
	
		
			
				|  |  |             return write(200, "获取成功", "data", map);
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             error(e);
 | 
	
		
			
				|  |  |             return error(-1, "获取失败!" + e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping("/getDoorOrderList")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "服务工单列表")
 | 
	
		
			
				|  |  |     public String getDoorOrderList(
 | 
	
		
			
				|  |  |             @ApiParam(value = "工单服务编号", name = "orderId",required = false)
 | 
	
		
			
				|  |  |             @RequestParam(value = "orderId", required = false) String orderId,
 | 
	
		
			
				|  |  |             @ApiParam(value = "居民姓名", name = "patientName",required = false)
 | 
	
		
			
				|  |  |             @RequestParam(value = "patientName", required = false) String patientName,
 | 
	
		
			
				|  |  |             @ApiParam(value = "联系方式", name = "patientPhone",required = false)
 | 
	
		
			
				|  |  |             @RequestParam(value = "patientPhone", required = false) String patientPhone,
 | 
	
		
			
				|  |  |             @ApiParam(value = "服务机构", name = "hospitalCode",required = false)
 | 
	
		
			
				|  |  |             @RequestParam(value = "hospitalCode", required = false) String hospitalCode,
 | 
	
		
			
				|  |  |             @ApiParam(value = "工单状态", name = "status",required = false)
 | 
	
		
			
				|  |  |             @RequestParam(value = "status", required = false) Integer[] status,
 | 
	
		
			
				|  |  |             @ApiParam(value = "创建时间开始,格式(yyyy-MM-dd mm:dd:ss)", name = "createTimeStart",required = false)
 | 
	
		
			
				|  |  |             @RequestParam(value = "createTimeStart", required = false) String createTimeStart,
 | 
	
		
			
				|  |  |             @ApiParam(value = "创建时间结束,格式(yyyy-MM-dd mm:dd:ss)", name = "createTimeEnd",required = false)
 | 
	
		
			
				|  |  |             @RequestParam(value = "createTimeEnd", required = false) String createTimeEnd,
 | 
	
		
			
				|  |  |             @ApiParam(value = "服务医生的名称", name = "serverDoctorName",required = false)
 | 
	
		
			
				|  |  |             @RequestParam(value = "serverDoctorName", required = false) String serverDoctorName,
 | 
	
		
			
				|  |  |             @ApiParam(value = "医生的code", name = "doctorCode",required = false)
 | 
	
		
			
				|  |  |             @RequestParam(value = "doctorCode", required = false) String doctorCode,
 | 
	
		
			
				|  |  |             @ApiParam(value = "角色0、医生,1、管理员", name = "isManage",required = false)
 | 
	
		
			
				|  |  |             @RequestParam(value = "isManage", required = false) String isManage,
 | 
	
		
			
				|  |  |             @ApiParam(value = "发起类型(1本人发起 2家人待预约 3医生代预约)", name = "type")
 | 
	
		
			
				|  |  |             @RequestParam(value = "type", required = false,defaultValue = "1") Integer type,
 | 
	
		
			
				|  |  |             @ApiParam(value = "页码", name = "page",defaultValue = "1",required = true)
 | 
	
		
			
				|  |  |             @RequestParam(value = "page", required = true) Integer page,
 | 
	
		
			
				|  |  |             @ApiParam(value = "每页数目", name = "pageSize",defaultValue = "10",required = true)
 | 
	
		
			
				|  |  |             @RequestParam(value = "pageSize", required = true) Integer pageSize) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(isManage)){
 | 
	
		
			
				|  |  |                 isManage = getCurrentRoleIsManange();
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if("0".equals(isManage)){
 | 
	
		
			
				|  |  |                 if(StringUtils.isEmpty(doctorCode)){
 | 
	
		
			
				|  |  |                     doctorCode=getUID();
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }else if ("1".equals(isManage) && StringUtils.isBlank(hospitalCode)){
 | 
	
		
			
				|  |  |                 //如果是管理员并且未筛选机构,就默认展示其管理下所有机构
 | 
	
		
			
				|  |  |                 String level = getCurrentRoleLevel();
 | 
	
		
			
				|  |  |                 String currentRoleCode = getCurrentRoleCode();
 | 
	
		
			
				|  |  |                 if(level.equals("2")) {
 | 
	
		
			
				|  |  |                     //市管理员
 | 
	
		
			
				|  |  |                     hospitalCode = currentRoleCode.substring(0, currentRoleCode.length() - 2) + "%";
 | 
	
		
			
				|  |  |                 }else if(level.equals("3")){
 | 
	
		
			
				|  |  |                     //区管理员
 | 
	
		
			
				|  |  |                     hospitalCode = currentRoleCode + "%";
 | 
	
		
			
				|  |  |                 }else if (level.equals("4")){
 | 
	
		
			
				|  |  |                     //机构管理员
 | 
	
		
			
				|  |  |                     hospitalCode = currentRoleCode;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }else if(StringUtils.isNotBlank(hospitalCode) && hospitalCode.length() < 10 ){
 | 
	
		
			
				|  |  |                 hospitalCode += "%";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             StringBuffer ss = new StringBuffer();
 | 
	
		
			
				|  |  |             if (status != null && status.length > 0){
 | 
	
		
			
				|  |  |                 int statusLength = status.length;
 | 
	
		
			
				|  |  |                 for (int i =0 ; i < statusLength ; i++){
 | 
	
		
			
				|  |  |                     ss .append(status[i]);
 | 
	
		
			
				|  |  |                     if (i<statusLength-1){
 | 
	
		
			
				|  |  |                         ss.append(",");
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 ss = null;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             JSONObject result = doctorDoorCoachOrderService.getDoorOrderList(orderId,patientName,patientPhone,hospitalCode,
 | 
	
		
			
				|  |  |                     ss,createTimeStart,createTimeEnd,serverDoctorName,doctorCode,page,pageSize, type);
 | 
	
		
			
				|  |  |             return write(200, "获取成功","data",result);
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |             return error(-1, "获取失败!" + e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping(value = "queryBriefList")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "调度员查询工单列表")
 | 
	
		
			
				|  |  |     public String queryBriefList(
 | 
	
		
			
				|  |  |             @ApiParam(name = "dispatcher", value = "调度员code") @RequestParam(value = "dispatcher", required = true) String dispatcher,
 | 
	
		
			
				|  |  |             @ApiParam(name = "hospital", value = "调度员所在机构code") @RequestParam(value = "hospital", required = true) String hospital,
 | 
	
		
			
				|  |  |             @ApiParam(name = "orderNumber", value = "工单号") @RequestParam(value = "orderNumber", required = false) String orderNumber,
 | 
	
		
			
				|  |  |             @ApiParam(name = "patientName", value = "工单服务对象姓名") @RequestParam(value = "patientName", required = false) String patientName,
 | 
	
		
			
				|  |  |             @ApiParam(name = "phone", value = "发起工单的居民的联系方式") @RequestParam(value = "phone", required = false) String phone,
 | 
	
		
			
				|  |  |             @ApiParam(name = "status", value = "工单状态") @RequestParam(value = "status", required = false) Integer status,
 | 
	
		
			
				|  |  |             @ApiParam(name = "patientType", value = "居民类型") @RequestParam(value = "patientType", required = false) String patientType,
 | 
	
		
			
				|  |  |             @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) {
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  |             JSONObject result = doctorDoorCoachOrderService.queryBriefList(dispatcher,hospital, orderNumber, patientName, phone, status,patientType, page, size);
 | 
	
		
			
				|  |  |             if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
 | 
	
		
			
				|  |  |                 return error(-1,result.getString(ResponseContant.resultMsg));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             int count = result.getIntValue(ResponseContant.count);
 | 
	
		
			
				|  |  |             JSONObject object = new JSONObject();
 | 
	
		
			
				|  |  |             object.put("total",count);
 | 
	
		
			
				|  |  |             object.put("detailModelList",result.get(ResponseContant.resultMsg));
 | 
	
		
			
				|  |  |             object.put("currPage",page);
 | 
	
		
			
				|  |  |             object.put("pageSize",size);
 | 
	
		
			
				|  |  |             return write(200,"查询成功","data",object);
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return error(-1,"查询失败");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping(value = "queryDoctorList")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "服务人员列表(医生列表)")
 | 
	
		
			
				|  |  |     public String queryDoctorList(
 | 
	
		
			
				|  |  |             @ApiParam(name = "hospital", value = "调度员所在的机构code") @RequestParam(value = "hospital", required = false) String hospital,
 | 
	
		
			
				|  |  |             @ApiParam(name = "doctorName", value = "医生姓名") @RequestParam(value = "doctorName", required = false) String doctorName,
 | 
	
		
			
				|  |  |             @ApiParam(name = "status", value = "医生接单状态,状态为全部时不传") @RequestParam(value = "status", required = false) String status,
 | 
	
		
			
				|  |  |             @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = false) String patient,
 | 
	
		
			
				|  |  |             @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) {
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  |             JSONObject result = doctorDoorCoachOrderService.queryDoctorList(patient,hospital, doctorName, status, page, size);
 | 
	
		
			
				|  |  |             if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
 | 
	
		
			
				|  |  |                 return error(-1,result.getString(ResponseContant.resultMsg));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             int count = result.getIntValue(ResponseContant.count);
 | 
	
		
			
				|  |  |             JSONObject object = new JSONObject();
 | 
	
		
			
				|  |  |             object.put("total",count);
 | 
	
		
			
				|  |  |             if (count > 0){
 | 
	
		
			
				|  |  |                 object.put("detailModelList",result.get(ResponseContant.resultMsg));
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 List list = new ArrayList();
 | 
	
		
			
				|  |  |                 object.put("detailModelList",list);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             object.put("currPage",page);
 | 
	
		
			
				|  |  |             object.put("pageSize",size);
 | 
	
		
			
				|  |  |             return write(200,"查询成功","data",object);
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return error(-1,"查询失败");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping("getByOrderId")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "根据工单id获取相应的工单,如果为空,则获取该医生当前最新一条的工单")
 | 
	
		
			
				|  |  |     public String getByOrderId(
 | 
	
		
			
				|  |  |             @ApiParam(value = "医生code", name = "doctor")
 | 
	
		
			
				|  |  |             @RequestParam(value = "doctor", required = true) String doctor,
 | 
	
		
			
				|  |  |             @ApiParam(value = "工单id", name = "orderId")
 | 
	
		
			
				|  |  |             @RequestParam(value = "orderId", required = false) String orderId) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             // 没有提供工单id的情况下,则获取该医生当前最新一条的工单
 | 
	
		
			
				|  |  |             if (StringUtils.isEmpty(orderId)) {
 | 
	
		
			
				|  |  |                 // 根据接单医生code获取最近一次服务orderId
 | 
	
		
			
				|  |  |                 orderId = doctorDoorCoachOrderService.getOrderIdByDoctor(doctor);
 | 
	
		
			
				|  |  |                 if (StringUtils.isEmpty(orderId)) {
 | 
	
		
			
				|  |  |                     return error(-1, "获取失败, 该医生暂无工单" );
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             // 根据orderId获取工单信息
 | 
	
		
			
				|  |  |             BaseDoorCoachOrderDO baseDoorCoachOrderDO = doctorDoorCoachOrderService.getDoorServiceOrderById(orderId);
 | 
	
		
			
				|  |  |             return write(200, "获取成功", "data", baseDoorCoachOrderDO);
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             error(e);
 | 
	
		
			
				|  |  |             return error(-1, "获取失败, 该医生暂无工单!" + e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取服务项目
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param hospital
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @GetMapping("selectItemsByHospital")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "获取服务项目")
 | 
	
		
			
				|  |  |     public String selectItemsByHospital(
 | 
	
		
			
				|  |  |             @ApiParam(value = "机构code", name = "hospital")
 | 
	
		
			
				|  |  |             @RequestParam(value = "hospital", required = false) String hospital,
 | 
	
		
			
				|  |  |             @ApiParam(value = "服务项目名称", name = "serverItemName")
 | 
	
		
			
				|  |  |             @RequestParam(value = "serverItemName", required = false) String serverItemName) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             return write(200, "获取成功","dara",patientDoorCoachOrderService.selectItemsByHospital(hospital,serverItemName));
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             error(e);
 | 
	
		
			
				|  |  |             return error(-1, "获取失败!" + e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @PostMapping("/initDoorStatus")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "初始化医生分派订单开关状态")
 | 
	
		
			
				|  |  |     public String initDoorStatus() {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             doctorDoorCoachOrderService.initDoorStatus();
 | 
	
		
			
				|  |  |             return success("成功");
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             error(e);
 | 
	
		
			
				|  |  |             return error(-1, "获取失败!" + e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping("/getDispatchOrderSwitch")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "获取医生分派订单开关状态")
 | 
	
		
			
				|  |  |     public String getDispatchOrderSwitch(
 | 
	
		
			
				|  |  |             @ApiParam(name = "doctor", value = "医生id")
 | 
	
		
			
				|  |  |             @RequestParam(value = "doctor", required = true) String doctor) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             String status = doctorDoorCoachOrderService.findDispatchStatusByDoctor(doctor);
 | 
	
		
			
				|  |  |             return write(200, "获取成功", "data", status);
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             error(e);
 | 
	
		
			
				|  |  |             return error(-1, "获取失败!" + e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @PostMapping("/dispatchOrderSwitch")
 | 
	
		
			
				|  |  |     @ApiOperation(value = "分派订单开关修改")
 | 
	
		
			
				|  |  |     public String dispatchOrderSwitch(
 | 
	
		
			
				|  |  |             @ApiParam(name = "doctor", value = "医生code")
 | 
	
		
			
				|  |  |             @RequestParam(value = "doctor", required = true) String doctor,
 | 
	
		
			
				|  |  |             @ApiParam(value = "开关值,5关闭 1开启", name = "value")
 | 
	
		
			
				|  |  |             @RequestParam(value = "value", required = true) Integer value) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             doctorDoorCoachOrderService.updateDispatchStatusByDoctor(doctor, value);
 | 
	
		
			
				|  |  |             return write(200, "修改成功");
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             error(e);
 | 
	
		
			
				|  |  |             return error(-1, "修改失败!" + e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @RequestMapping(value = "/urlAnalysis",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
 | 
	
		
			
				|  |  |     @ApiOperation("门牌解析上门地址")
 | 
	
		
			
				|  |  |     @ResponseBody
 | 
	
		
			
				|  |  |     public String urlAnalysis(@ApiParam(name = "url", value = "地址解析", defaultValue = "")
 | 
	
		
			
				|  |  |                               @RequestParam(value = "url", required = true)String url)throws Exception {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             return write(200, "操作成功!","data",doctorDoorCoachOrderService.urlAnalysis(url));
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             //日志文件中记录异常信息
 | 
	
		
			
				|  |  |             error(e);
 | 
	
		
			
				|  |  |             //返回接口异常信息处理结果
 | 
	
		
			
				|  |  |             return error(-1, "操作失败!");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |