package com.hx.phip.controller.appointment;
|
|
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONObject;
|
import com.hx.common.BaseController;
|
import com.hx.exception.TipsException;
|
import com.hx.phiappt.util.appointment.AppointmentListUtil;
|
import com.hx.guide.util.CommonQueryUtil;
|
import com.hx.mybatisTool.SqlSentence;
|
import com.hx.phiappt.common.OperatorConstants;
|
import com.hx.phiappt.common.RoleType;
|
import com.hx.phiappt.common.UserStatusConstants;
|
import com.hx.phiappt.constants.tool.appointment.AppointmentTool;
|
import com.hx.phiappt.constants.tool.appointment.TransferUtil;
|
import com.hx.phiappt.dao.mapper.*;
|
import com.hx.phiappt.model.*;
|
import com.hx.phiappt.util.AppointmentV2Util;
|
import com.hx.phiappt.vo.OperatorVo;
|
import com.hx.phip.service.EmployeeRoleService;
|
import com.hx.phip.service.EmployeeService;
|
import com.hx.phip.service.SystemParameterService;
|
import com.hx.phip.service.appointment.AppointmentService;
|
import com.hx.phip.service.appointment.AppointmentV2Service;
|
import com.hx.resultTool.Result;
|
import com.hx.util.DateUtil;
|
import com.hx.util.StringUtils;
|
import com.hz.his.dto.appointment.AppointmentV2Dto;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.annotation.Resource;
|
import java.util.*;
|
|
/**
|
* 预约处理
|
* @USER: fhx
|
* @DATE: 2023/7/5
|
**/
|
@Slf4j
|
@RestController
|
@RequestMapping("/appointment")
|
public class AppointmentController extends BaseController {
|
|
@Resource
|
private AppointmentService appointmentService;
|
@Resource
|
private SystemParameterService systemParameterService;
|
@Resource
|
private AppointmentV2Service appointmentV2Service;
|
@Resource
|
private EmployeeRoleService employeeRoleService;
|
@Resource
|
private EmployeeService employeeService;
|
|
/** 新增预约 */
|
@RequestMapping("/add")
|
public Result add(@RequestBody AppointmentV2Dto dto) {
|
log.info("新增预约参数:{}", JSONObject.toJSONString(dto));
|
//获取操作人信息
|
OperatorVo operatorVo = getOperatorInfo(dto);
|
|
if (StringUtils.isEmpty(dto.getShopId())) {
|
throw new TipsException("请选择门店!");
|
}
|
|
if (StringUtils.isEmpty(dto.getUserId())) {
|
throw new TipsException("请选择用户!");
|
}
|
|
if (StringUtils.isEmpty(dto.getStartTime())) {
|
throw new TipsException("请选择预约时间!");
|
}
|
|
if (dto.getAddMode() == null) {
|
throw new TipsException("预约方式为空!");
|
}
|
|
if (dto.getVisitType() == null) {
|
throw new TipsException("请选择就诊类型!");
|
}
|
|
if (dto.getAppType() == null) {
|
throw new TipsException("请选择预约类型!");
|
}
|
|
if (dto.getIsMicApprove() == BaseEntity.YES){
|
if(dto.getAddMode() == Appointment.ADD_MODE_ADVISER_V2_3 && StringUtils.isEmpty(dto.getImgUrls())){
|
throw new TipsException("MIC同意必须选择图片!");
|
}
|
}
|
|
String corpUserId = StringUtils.isEmpty(dto.getCorpUserId()) ? null : dto.getCorpUserId();
|
//员工预约时
|
Employee employee = checkEmployee(operatorVo, corpUserId);
|
|
Shop shop = commonService.selectOneByKey(ShopMapper.class, dto.getShopId());
|
if(shop == null) {
|
throw new TipsException("查询不到预约门店信息!");
|
}
|
|
User user = commonService.selectOneByKey(UserMapper.class, dto.getUserId());
|
if(user == null) {
|
throw new TipsException("找不到用户");
|
}
|
|
//用户自助预约时,判断使用用户所属顾问为预约顾问
|
if(dto.getAddMode() == Appointment.ADD_MODE_CRM_SELF && StringUtils.noNull(user.getHisCorpUserId())){
|
corpUserId = user.getHisCorpUserId();
|
}
|
|
String doctorId = dto.getDoctorId();
|
if(!StringUtils.isEmpty(doctorId) && !"null".equals(doctorId))
|
{
|
Employee doctor = employeeService.selectOneByIdAndRole(doctorId, RoleType.UNIQUE_STR_DOCTOR);
|
if(doctor == null)
|
throw new TipsException("找不到医生");
|
}else{
|
doctorId = null;
|
}
|
|
if(dto.getSpecialUser() == null) {
|
dto.setSpecialUser(BaseEntity.NO);
|
}
|
|
if(dto.getIsSwitch() == null) {
|
dto.setIsSwitch(BaseEntity.NO);
|
}
|
|
if(dto.getObeyDoctor() == null) {
|
dto.setObeyDoctor(BaseEntity.NO);
|
}
|
|
if(dto.getObeyTime() == null) {
|
dto.setObeyTime(BaseEntity.NO);
|
}
|
|
if(dto.getIsSendMsg() == null) {
|
dto.setIsSendMsg(BaseEntity.NO);
|
}
|
|
if(dto.getIsArriveSendMsg() == null) {
|
dto.setIsArriveSendMsg(BaseEntity.NO);
|
}
|
|
if(dto.getWaitTime() == null) {
|
dto.setWaitTime(BaseEntity.NO);
|
}
|
|
if(dto.getGtTime() == null || dto.getMzTime() == null || dto.getMfTime() == null || dto.getSqTime() == null || dto.getZlTime() == null || dto.getWaitTime() == null
|
|| dto.getGtTime() < 0 || dto.getMzTime() < 0 || dto.getMfTime() < 0 || dto.getSqTime() < 0 || dto.getZlTime() < 0 || dto.getWaitTime() < 0)
|
{
|
throw new TipsException("请填写正确的沟通时间、面诊时间、麻敷时间、术前准备时间、治疗准备开始时间、治疗时间");
|
}
|
|
Integer duration = dto.getGtTime() + dto.getMzTime() + dto.getMfTime() + dto.getSqTime() + dto.getZlTime() + dto.getWaitTime();
|
|
Date st = DateUtil.parseString(dto.getStartTime(), "yyyy-MM-dd HH:mm:ss");
|
Date et = DateUtil.parseString(dto.getEndTime(), "yyyy-MM-dd HH:mm:ss");
|
//结束时间为空则根据总时长算出来
|
if(et == null){
|
Calendar ca = Calendar.getInstance();
|
ca.setTime(st);
|
ca.add(Calendar.MINUTE, duration);
|
et = ca.getTime();
|
}
|
|
//检测用户创建预约
|
checkUserAdd(dto.getAddMode(), dto.getDoctorId(), st, et);
|
|
//预约关联项目
|
List<Project> projectList = new ArrayList<>();
|
List<AppointmentProject> apList = getAppointmentProjectList(dto, projectList);
|
|
//医生限制数量校验
|
AppointmentTool.doctorLimitPreNumCheck(dto.getShopId(),null,doctorId,st,commonService);
|
//检测非繁忙项目
|
int rulePreType = AppointmentTool.preProjectNonBusy(dto.getShopId(),null,st, projectList,null,commonService);
|
|
//检查是否不占用转疗名额
|
Integer occupySwitch = dto.getIsSwitch();
|
if(BaseEntity.YES.equals(occupySwitch)){
|
occupySwitch = TransferUtil.checkTransferNotOccupy(commonService
|
, user.getUserLevel(), dto.getShopId() , st, doctorId, employee , projectList);
|
}
|
|
Map<String, Object> map = new HashMap<>();
|
SqlSentence sqlSentence = new SqlSentence();
|
sqlSentence.setM(map);
|
String dayStr = DateUtil.formatDate(st);
|
|
Appointment appointment = new Appointment();
|
appointment.setShopId(dto.getShopId());
|
appointment.setCorpUserId(corpUserId);
|
appointment.setDoctorId(doctorId);
|
appointment.setObeyDoctor(dto.getObeyDoctor());
|
appointment.setUserId(dto.getUserId());
|
appointment.setStartTime(st);
|
appointment.setEndTime(et);
|
appointment.setDuration(duration);
|
appointment.setVisitType(dto.getVisitType());
|
appointment.setAppType(dto.getAppType());
|
appointment.setComDuration(dto.getGtTime());
|
appointment.setDocComDuration(dto.getMzTime());
|
appointment.setReadyDuration(dto.getSqTime());
|
appointment.setProDuration(0);
|
appointment.setPalsyDuration(dto.getMfTime());
|
appointment.setTreatDuration(dto.getZlTime());
|
appointment.setRemark(dto.getRemark());
|
appointment.setObeyTime(dto.getObeyTime());
|
appointment.setSpecialUser(dto.getSpecialUser());
|
appointment.setOccupySwitch(occupySwitch);
|
appointment.setRulePreType(rulePreType);
|
appointment.setDayStr(dayStr);
|
appointment.setMonthStr(dayStr.substring(0, 6));
|
appointment.setIsSwitch(dto.getIsSwitch());
|
appointment.setIsAnaesthesia(dto.getMfTime() > 0 ? BaseEntity.YES : BaseEntity.NO);
|
appointment.setIsMicApprove(dto.getIsMicApprove());
|
//新创建人信息
|
appointment.setCreateManId(operatorVo.getOpId());
|
appointment.setCreateManName(operatorVo.getOpName());
|
if(operatorVo.getOpType() == OperatorConstants.OP_TYPE_EMPLOYEE){
|
appointment.setCreateManType(Appointment.CREATE_MAN_TYPE_EMPLOYEE);
|
appointment.setCreateCorpUserId(operatorVo.getOpId());
|
appointment.setCreateRoleId(operatorVo.getOpRoleId());
|
appointment.setCreateRoleStr(operatorVo.getRoleStr());
|
}else if(operatorVo.getOpType() == OperatorConstants.OP_TYPE_USER){
|
appointment.setCreateManType(Appointment.CREATE_MAN_TYPE_USER);
|
}else {
|
appointment.setCreateManType(Appointment.CREATE_MAN_TYPE_UNKNOWN);
|
}
|
appointment.setImgUrls(dto.getImgUrls());
|
appointment.setProjectIds(dto.getProjectIds());
|
appointment.setProjectNames(dto.getProjectNames());
|
appointment.setProjectJson(dto.getProjectJson());
|
appointment.setStatus(Appointment.STATUS_WAIT);
|
appointment.setActivityDayId(dto.getActivityDayId());
|
appointment.setIsSendMsg(dto.getIsSendMsg());
|
appointment.setIsArriveSendMsg(dto.getIsArriveSendMsg());
|
//标记预约的新增模式
|
appointment.setAddMode(dto.getAddMode());
|
//多余的等待时间
|
appointment.setWaitDuration(dto.getWaitTime());
|
//医生治疗时间
|
appointment.setDoctorZlDuration(dto.getDoctorZlTime());
|
//判断 预约所属顾问是否为空 为空则为预分诊预约,不为空则为普通预约
|
if(StringUtils.isEmpty(corpUserId)){
|
appointment.setIsPretriage(BaseEntity.YES);
|
}
|
//周,取当前周一
|
appointment.setWeekStr(DateUtil.formatDate(getWeekDate(st)));
|
//预约冲突原因
|
appointment.setConflictReason(dto.getConflictReason());
|
|
//处理预约状态和是否转疗逻辑
|
handleStatusAndIsSwitch(dto.getAddMode(), appointment, shop, employee, false, null);
|
|
//获取设备相关数据
|
List<AppointmentProjectDeviceNo> apdnList = new ArrayList<>();
|
List<DeviceNoSchedule> dnsList = AppointmentV2Util.handleDeviceTime(dto.getDeviceTimeJson(), apdnList);
|
|
//治疗开始时间
|
Calendar ca = Calendar.getInstance();
|
ca.setTime(st);
|
ca.add(Calendar.MINUTE, duration - appointment.getTreatDuration());
|
Date treatSt = ca.getTime();
|
|
//获取出医生的治疗时间记录
|
|
List<DoctorTime> doctorTimeList = null;
|
//后台预约时,zlTimeJson没有对应的开始结束时间,所以要特殊处理
|
if(dto.getAddMode() == Appointment.ADD_MODE_BACKSTAGE_V2_3){
|
List<Integer> doctorZlTime = new ArrayList<>();
|
doctorZlTime.add(0);
|
net.sf.json.JSONArray newZlTimeJson = new net.sf.json.JSONArray();
|
|
doctorTimeList = AppointmentV2Util.getDoctorZlTime(dto.getZlTimeJson(), treatSt
|
, doctorId, dto.getShopId(), dayStr , appointment.getMonthStr(), doctorZlTime
|
, newZlTimeJson, dnsList);
|
appointment.setDoctorZlDuration(doctorZlTime.get(0));
|
}else{
|
doctorTimeList = AppointmentV2Util.getDoctorZlTime(dto.getZlTimeJson(), dto.getShopId(), doctorId, dayStr, dayStr.substring(0, 6));
|
}
|
|
AppointmentInfo appointmentInfo = new AppointmentInfo();
|
appointmentInfo.setZlTimeJson(dto.getZlTimeJson());
|
appointmentInfo.setDeviceTimeJson(dto.getDeviceTimeJson());
|
appointmentInfo.setAutoTimeType(dto.getHandleNum());
|
appointmentInfo.setMealsRemark(dto.getMealsRemark());
|
if(!StringUtils.isEmpty(dto.getBirthday())){
|
appointmentInfo.setBirthday(DateUtil.parseString_2(dto.getBirthday()));
|
}
|
//填充冗余用户状态
|
appointmentInfo.setUserStatus(user.getUserStatus());
|
appointmentInfo.setUserStatusCn(UserStatusConstants.getName(user.getUserStatus()));
|
appointmentInfo.setUserInternetCorpUserId(user.getInternetCorpUserId());
|
appointmentInfo.setUserInternetCorpUserName(CommonQueryUtil.getEmployeeName(user.getInternetCorpUserId(), commonService));
|
appointmentInfo.setUserConsultantId(user.getHisCorpUserId());
|
appointmentInfo.setUserConsultantName(CommonQueryUtil.getEmployeeName(user.getHisCorpUserId(), commonService));
|
appointmentInfo.setUserShopId(user.getShopId());
|
appointmentInfo.setUserShopName(CommonQueryUtil.getShopName(user.getShopId(), commonService));
|
appointmentInfo.setUserLevel(user.getUserLevel());
|
appointmentInfo.setMemberLevelId(user.getMemberLevelId());
|
|
//添加预约
|
appointmentV2Service.add(operatorVo, user, appointment, appointmentInfo, apList, apdnList, doctorTimeList, dnsList);
|
|
JSONObject obj = new JSONObject();
|
obj.put("id", appointment.getId());
|
return Result.success(obj);
|
}
|
|
/** 编辑预约 */
|
@RequestMapping("/edit")
|
public Result edit(@RequestBody AppointmentV2Dto dto) {
|
log.info("编辑预约参数:{}", JSONObject.toJSONString(dto));
|
//获取操作人信息
|
OperatorVo operatorVo = getOperatorInfo(dto);
|
|
if(StringUtils.isEmpty(dto.getId())) {
|
throw new TipsException("预约标识为空!");
|
}
|
|
if (dto.getAddMode() == null) {
|
throw new TipsException("预约方式为空!");
|
}
|
|
Appointment appointment = commonService.selectOneByKey(AppointmentMapper.class, dto.getId());
|
if(appointment == null) {
|
throw new TipsException("查询不到预约信息!");
|
}
|
appointment.setOrStartTime(appointment.getStartTime());
|
|
if(appointment.getAddMode() == Appointment.ADD_MODE_CRM_SELF){
|
throw new TipsException("用户自助预约无法编辑!");
|
}
|
|
AppointmentInfo appointmentInfo = appointmentV2Service.selectOneByApptId(appointment.getId());
|
if(appointmentInfo == null){
|
throw new TipsException("查询不到预约其他信息!");
|
}
|
|
User user = commonService.selectOneByKey(UserMapper.class, appointment.getUserId());
|
if(user == null){
|
throw new TipsException("查询不到预约用户信息!");
|
}
|
|
//复制一个旧预约信息对象
|
Appointment oldInfo = new Appointment();
|
BeanUtils.copyProperties(appointment, oldInfo);
|
|
//顾问或顾问助理,才判断所属顾问id不能为空
|
String corpUserId = StringUtils.isEmpty(dto.getCorpUserId()) ? null : dto.getCorpUserId();
|
Employee employee = checkEmployee(operatorVo, corpUserId);
|
|
if(oldInfo.getStatus() == Appointment.STATUS_CANCEL) {
|
throw new TipsException("已取消的预约不能修改!");
|
}
|
|
if(oldInfo.getCancelStatus() == Appointment.CANCEL_STATUS_APPLY) {
|
throw new TipsException("申请取消中的预约不能修改!");
|
}
|
|
if(oldInfo.getStatus() == Appointment.STATUS_SUC && oldInfo.getIsArrive() == BaseEntity.YES) {
|
throw new TipsException("已到店的预约不能修改!");
|
}
|
|
if(StringUtils.isEmpty(dto.getStartTime())) {
|
throw new TipsException("请选择预约时间!");
|
}
|
|
Date st = DateUtil.parseString_1(dto.getStartTime());
|
if(st == null) {
|
throw new TipsException("请选择预约时间!");
|
}
|
|
if(dto.getAppType() == null) {
|
throw new TipsException("请选择预约类型!");
|
}
|
|
if(dto.getGtTime() == null || dto.getMzTime() == null || dto.getMfTime() == null || dto.getSqTime() == null || dto.getZlTime() == null || dto.getWaitTime() == null
|
|| dto.getGtTime() < 0 || dto.getMzTime() < 0 || dto.getMfTime() < 0 || dto.getSqTime() < 0 || dto.getZlTime() < 0 || dto.getWaitTime() < 0) {
|
throw new TipsException("请填写正确的沟通时间、面诊时间、麻敷时间、术前准备时间、治疗准备开始时间、治疗时间!");
|
}
|
|
//自动计算预约时长
|
Integer duration = dto.getGtTime() + dto.getMzTime() + dto.getMfTime() + dto.getSqTime() + dto.getZlTime() + dto.getWaitTime();
|
|
|
//把传过来的时间减去沟通时间
|
Calendar calendar = Calendar.getInstance();
|
calendar.setTime(st);
|
Calendar ca = Calendar.getInstance();
|
ca.setTime(st);
|
ca.add(Calendar.MINUTE, duration);
|
Date et = ca.getTime();
|
|
if(StringUtils.noNull(dto.getShopId())) {
|
appointment.setShopId(dto.getShopId());
|
}
|
|
Shop shop = commonService.selectOneByKey(ShopMapper.class, appointment.getShopId());
|
if(shop == null){
|
throw new TipsException("查询不到预约门店信息!");
|
}
|
|
if(dto.getSpecialUser() != null){
|
appointment.setSpecialUser(dto.getSpecialUser());
|
}
|
|
if(dto.getRealComDuration() != null) {
|
appointment.setRealComDuration(dto.getRealComDuration());
|
}
|
|
if(dto.getRealDocComDuration() != null) {
|
appointment.setRealDocComDuration(dto.getRealDocComDuration());
|
}
|
|
if(dto.getRealDuration() != null) {
|
appointment.setRealDuration(dto.getRealDuration());
|
}
|
|
if(dto.getRealProDuration() != null) {
|
appointment.setRealProDuration(dto.getRealProDuration());
|
}
|
|
if(dto.getRealTreatDuration() != null) {
|
appointment.setRealTreatDuration(dto.getRealTreatDuration());
|
}
|
|
if(dto.getRealReadyDuration() != null) {
|
appointment.setRealReadyDuration(dto.getRealReadyDuration());
|
}
|
|
if(dto.getRealWaitDuration() != null){
|
appointment.setRealWaitDuration(dto.getRealWaitDuration());
|
}
|
|
if(dto.getRealPalsyDuration() != null){
|
appointment.setRealPalsyDuration(dto.getRealPalsyDuration());
|
}
|
|
if(dto.getIsArrive() != null) {
|
appointment.setIsArrive(dto.getIsArrive());
|
}
|
|
if(dto.getIsMicApprove() != null){
|
appointment.setIsMicApprove(dto.getIsMicApprove());
|
}
|
|
//HIS助手编辑
|
if (dto.getAddMode() == Appointment.ADD_MODE_ADVISER_V2_3
|
&& appointment.getIsMicApprove() == BaseEntity.YES
|
&& StringUtils.isEmpty(dto.getImgUrls())){
|
throw new TipsException("MIC同意必须选择图片!");
|
}
|
|
if(StringUtils.noNull(dto.getImgUrls())){
|
appointment.setImgUrls(dto.getImgUrls());
|
}
|
|
if(dto.getObeyDoctor() != null){
|
appointment.setObeyDoctor(dto.getObeyDoctor());
|
}
|
|
if(dto.getObeyTime() != null){
|
appointment.setObeyTime(dto.getObeyTime());
|
}
|
|
if(appointment.getIsArrive() == BaseEntity.YES && oldInfo.getIsArrive() == BaseEntity.NO) {
|
if (oldInfo.getStatus() != Appointment.STATUS_SUC
|
|| oldInfo.getCancelStatus() == Appointment.CANCEL_STATUS_APPLY) {
|
throw new TipsException("该预约非确认状态或者申请取消中!");
|
}
|
}
|
|
if(dto.getIsSwitch() != null) {
|
appointment.setIsSwitch(dto.getIsSwitch());
|
}
|
|
if(StringUtils.noNull(dto.getVisitType())) {
|
appointment.setVisitType(dto.getVisitType());
|
}
|
|
if(dto.getIsSendMsg() != null) {
|
dto.setIsSendMsg(appointment.getIsSendMsg() != null ? appointment.getIsSendMsg() : BaseEntity.NO);
|
}
|
|
if (dto.getIsArriveSendMsg() != null){
|
appointment.setIsArriveSendMsg(dto.getIsArriveSendMsg());
|
}
|
|
String dayStr = DateUtil.formatDate(st);
|
|
|
//预约关联项目
|
List<Project> projectList = new ArrayList<>();
|
List<AppointmentProject> apList = getAppointmentProjectList(dto, projectList);
|
//医生限制数量校验
|
AppointmentTool.doctorLimitPreNumCheck(dto.getShopId(), appointment.getId(), dto.getDoctorId(), st ,commonService);
|
//检测非繁忙项目
|
int rulePreType = AppointmentTool.preProjectNonBusy(dto.getShopId(), appointment.getId(),st,projectList,null,commonService);
|
|
//检查是否不占用转疗名额
|
Integer occupySwitch = dto.getIsSwitch();
|
if(BaseEntity.YES.equals(occupySwitch)){
|
occupySwitch = TransferUtil.checkTransferNotOccupy(commonService
|
, appointmentInfo==null?null:appointmentInfo.getUserLevel(), dto.getShopId() , st, dto.getDoctorId(), employee , projectList);
|
}
|
|
//获取设备相关数据
|
List<AppointmentProjectDeviceNo> apdnList = new ArrayList<>();
|
List<DeviceNoSchedule> dnsList = AppointmentV2Util.handleDeviceTime(dto.getDeviceTimeJson(), apdnList);
|
//获取出医生的治疗时间记录
|
List<DoctorTime> doctorTimeList = null;
|
//后台预约时,zlTimeJson没有对应的开始结束时间,所以要特殊处理
|
if(dto.getAddMode() == Appointment.ADD_MODE_BACKSTAGE_V2_3){
|
List<Integer> doctorZlTime = new ArrayList<>();
|
doctorZlTime.add(0);
|
net.sf.json.JSONArray newZlTimeJson = new net.sf.json.JSONArray();
|
//治疗开始时间
|
ca.setTime(st);
|
ca.add(Calendar.MINUTE, duration - dto.getZlTime());
|
Date treatSt = ca.getTime();
|
doctorTimeList = AppointmentV2Util.getDoctorZlTime(dto.getZlTimeJson(), treatSt
|
, dto.getDoctorId(), dto.getShopId(), dayStr , appointment.getMonthStr(), doctorZlTime
|
, newZlTimeJson, dnsList);
|
appointment.setDoctorZlDuration(doctorZlTime.get(0));
|
}else{
|
doctorTimeList = AppointmentV2Util.getDoctorZlTime(dto.getZlTimeJson(), dto.getShopId(), dto.getDoctorId(), dayStr, dayStr.substring(0, 6));
|
}
|
|
// if(isChangeTime == 1 || dto.getIsProjectChange() == 1) {
|
// String [] projectIdsArr = StringUtils.isEmpty(dto.getProjectIds()) ? new String[0] : dto.getProjectIds().split(",");
|
// //重新判断活动日
|
// ActivityDay activityDay = getActivityDay(dto.getShopId(), dayStr, dto.getDoctorId(), projectIdsArr);
|
// //预约开始时间在活动时间段里面
|
// if(activityDay != null && st.compareTo(activityDay.getStartTime()) != -1 && st.compareTo(activityDay.getEndTime()) < 1){
|
// appointment.setActivityDayId(activityDay.getId());
|
// }else{
|
// appointment.setActivityDayId(null);
|
// }
|
// }
|
|
//赋值对应字段
|
appointment.setAddMode(dto.getAddMode());
|
appointment.setEditTime(new Date());
|
appointment.setDuration(duration);
|
appointment.setPalsyDuration(dto.getMfTime());
|
appointment.setComDuration(dto.getGtTime());
|
appointment.setDocComDuration(dto.getMzTime());
|
appointment.setTreatDuration(dto.getZlTime());
|
appointment.setReadyDuration(dto.getSqTime());
|
appointment.setWaitDuration(dto.getWaitTime());
|
appointment.setStartTime(st);
|
appointment.setEndTime(et);
|
appointment.setDayStr(dayStr);
|
appointment.setWeekStr(DateUtil.formatDate(getWeekDate(st)));
|
|
appointment.setIsAnaesthesia(dto.getMfTime() > 0 ? BaseEntity.YES : BaseEntity.NO);
|
appointment.setNotifyStatus(Appointment.NOTIFY_STATUS_SUC);
|
appointment.setSpecialUser(dto.getSpecialUser());
|
appointment.setOccupySwitch(occupySwitch);
|
appointment.setRulePreType(rulePreType);
|
|
appointment.setDoctorId(dto.getDoctorId());
|
appointment.setNurseId(dto.getNurseId());
|
appointment.setCorpUserId(corpUserId);
|
appointment.setRemark(dto.getRemark());
|
appointment.setProjectIds(dto.getProjectIds());
|
appointment.setProjectNames(dto.getProjectNames());
|
appointment.setProjectJson(dto.getProjectJson());
|
appointment.setComRoomId(dto.getComRoomId());
|
appointment.setTreatRoomId(dto.getTreatRoomId());
|
appointment.setConflictReason(dto.getConflictReason());
|
//如果预约已审核,则记录一下已审核修改
|
if(appointment.getStatus() == Appointment.STATUS_SUC || appointment.getStatus() == Appointment.STATUS_FAIL) {
|
appointment.setIsModify(BaseEntity.YES);
|
}
|
|
//预约其他信息
|
appointmentInfo.setAutoTimeType(dto.getHandleNum());
|
appointmentInfo.setZlTimeJson(dto.getZlTimeJson());
|
appointmentInfo.setDeviceTimeJson(dto.getDeviceTimeJson());
|
appointmentInfo.setMealsRemark(dto.getMealsRemark());
|
if(!StringUtils.isEmpty(dto.getBirthday())){
|
appointmentInfo.setBirthday(DateUtil.parseString_2(dto.getBirthday()));
|
}
|
|
//处理预约状态和是否转疗逻辑
|
handleStatusAndIsSwitch(dto.getAddMode(), appointment, shop, employee, true, oldInfo);
|
|
appointmentV2Service.edit(operatorVo, user, oldInfo, appointment, appointmentInfo, apList, apdnList, doctorTimeList, dnsList);
|
|
return Result.success();
|
}
|
|
/** 取消预约 */
|
@RequestMapping("/cancel")
|
public Result cancel(@RequestBody AppointmentV2Dto dto){
|
log.info("取消预约参数:{}", JSONObject.toJSONString(dto));
|
|
OperatorVo operatorVo = getOperatorInfo(dto);
|
|
if(StringUtils.isEmpty(dto.getId())) {
|
throwParamException("预约标识为空!");
|
}
|
|
// if(StringUtils.isEmpty(dto.getAnnexUrl())) {
|
// throwParamException("对话凭证不能为空!");
|
// }
|
|
Appointment appointment = commonService.selectOneByKey(AppointmentMapper.class, dto.getId());
|
if(appointment == null) {
|
throwParamException("查询不到预约信息!");
|
}
|
|
if(appointment.getStatus() == Appointment.STATUS_FAIL || appointment.getStatus() == Appointment.STATUS_CANCEL) {
|
throwServiceException("预约不成功或者已取消!");
|
}
|
|
if(appointment.getCancelStatus() != Appointment.CANCEL_STATUS_NONE && appointment.getCancelStatus() != Appointment.CANCEL_STATUS_FAIL) {
|
throwServiceException("取消状态不正确!");
|
}
|
|
//判断用户自助的预约,操作人非用户时,不能取消
|
if(appointment.getAddMode() == Appointment.ADD_MODE_CRM_SELF
|
&& !operatorVo.getOpId().equals(appointment.getCreateManId())){
|
throw new TipsException("无法取消用户的自助预约!");
|
}
|
|
Integer isSendMsg = dto.getIsSendMsg();
|
if(isSendMsg == null) {
|
isSendMsg = appointment.getIsSendMsg() != null ? appointment.getIsSendMsg() : BaseEntity.NO;
|
}
|
|
appointmentV2Service.cancel(appointment, operatorVo, dto.getRemark(), isSendMsg, dto.getAnnexUrl());
|
|
return Result.success();
|
}
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
/** 获取操作人信息 */
|
private OperatorVo getOperatorInfo(AppointmentV2Dto dto){
|
|
if(dto.getOpType() == null){
|
throw new TipsException("操作人类型为空!");
|
}
|
|
if(StringUtils.isEmpty(dto.getOpId())){
|
throw new TipsException("操作人标识为空!");
|
}
|
|
OperatorVo operatorVo = null;
|
if(dto.getOpType() == OperatorConstants.OP_TYPE_EMPLOYEE){
|
if(StringUtils.isEmpty(dto.getOpRoleId())){
|
throw new TipsException("操作人角色标识为空!");
|
}
|
Employee employee = employeeRoleService.selectEmployeeById(dto.getOpRoleId());
|
if(employee == null){
|
throw new TipsException("查询不到员工操作人信息!");
|
}
|
operatorVo = new OperatorVo(employee);
|
}else if(dto.getOpType() == OperatorConstants.OP_TYPE_USER){
|
User user = commonService.selectOneByKey(UserMapper.class, dto.getOpId());
|
if(user == null){
|
throw new TipsException("查询不到用户操作人信息!");
|
}
|
operatorVo = new OperatorVo(user);
|
} else {
|
throw new TipsException("操作人类型错误!");
|
}
|
return operatorVo;
|
}
|
|
//校验员工判断
|
private Employee checkEmployee(OperatorVo operatorVo, String corpUserId){
|
if(operatorVo.getOpType() == OperatorConstants.OP_TYPE_EMPLOYEE){
|
//顾问或顾问助理,才判断所属顾问id不能为空
|
// if(RoleType.UNIQUE_STR_ADVISER_ASSISTANT.equals(operatorVo.getRoleStr())
|
// || RoleType.UNIQUE_STR_ADVISER_LEADER.equals(operatorVo.getRoleStr()) ){
|
// if(StringUtils.isEmpty(corpUserId)){
|
// throw new TipsException("请选择预约所属顾问!");
|
// }
|
// }
|
|
if(operatorVo.getEmployee() == null){
|
throw new TipsException("预约操作员工信息为空[020]");
|
}
|
return operatorVo.getEmployee();
|
}
|
return null;
|
}
|
|
//获取预约项目
|
private List<AppointmentProject> getAppointmentProjectList(AppointmentV2Dto dto, List<Project> projectList){
|
|
//预约关联项目
|
Project project;
|
AppointmentProject appointmentProject = null;
|
List<AppointmentProject> apList = new ArrayList<>();
|
|
String[] projectIdArr = StringUtils.isEmpty(dto.getProjectIds()) ? new String[0] : dto.getProjectIds().split(",");
|
//复查时可不选预约项目
|
if(StringUtils.isEmpty(dto.getProjectIds(), dto.getProjectJson()) || projectIdArr == null || projectIdArr.length <= 0) {
|
if(dto.getAppType() != Appointment.APP_TYPE_REVIEW){
|
throw new TipsException("请选择项目!");
|
}
|
}else{
|
JSONArray arr = JSONArray.parseArray(dto.getProjectJson());
|
JSONObject json;
|
for(int i = 0; i < arr.size(); i++){
|
json = arr.getJSONObject(i);
|
//查找预约项目
|
project = commonService.selectOneByKey(ProjectMapper.class, json.getString("id"));
|
if(project == null || project.getIsDel().equals(BaseEntity.YES) || project.getIsUp().equals(BaseEntity.NO)) {
|
throw new TipsException("查询不到项目或者项目已下架!");
|
}
|
projectList.add(project);
|
appointmentProject = new AppointmentProject(json);
|
apList.add(appointmentProject);
|
}
|
}
|
|
return apList;
|
|
}
|
|
//处理预约状态和是否转疗逻辑
|
private void handleStatusAndIsSwitch(Integer addMode, Appointment appointment, Shop shop, Employee employee, boolean isEdit, Appointment oldInfo) {
|
|
//默认状态:待审核
|
appointment.setStatus(Appointment.STATUS_WAIT);
|
|
//CRM预约的默认状态:预约成功
|
if(addMode == Appointment.ADD_MODE_CRM_SELF){
|
appointment.setStatus(Appointment.STATUS_SUC);
|
return;
|
}
|
|
//要MIC同意的则跳过
|
if(appointment.getIsMicApprove() == BaseEntity.YES){
|
return;
|
}
|
|
//非HIS助手顾问新增、后台信息的
|
if(addMode != Appointment.ADD_MODE_ADVISER_V2_3
|
&& addMode != Appointment.ADD_MODE_BACKSTAGE_V2_3
|
&& addMode != Appointment.ADD_MODE_BACKSTAGE_V2_4){
|
return;
|
}
|
|
//判断系统是否设置了自动审核成功
|
SystemParameter systemParameter = systemParameterService.selectOneByName(SystemParameter.KEY_APP_AUTO_EXAMINE_SUC);
|
if(systemParameter == null || !"1".equals(systemParameter.getParamValue())){
|
return;
|
}
|
appointment.setStatus(Appointment.STATUS_SUC);
|
|
//判断是否会占用转疗,不占用跳过
|
if(BaseEntity.NO.equals(appointment.getOccupySwitch())){
|
return;
|
}
|
|
if(!isEdit){
|
//新增预约判断:预约门店和预约员工门店不一致,判断门店是否还有转疗数量
|
if(!appointment.getShopId().equals(employee.getShopId())){
|
int countIsSwitch = appointmentV2Service.selectCountIsSwitch(appointment.getDayStr(), shop.getId());
|
log.info("新增预约:{}{}转疗单数:{},门店设置最大的转疗数:{}", shop.getName(), appointment.getDayStr(), countIsSwitch, shop.getMaxSwitchNum());
|
if(shop !=null && shop.getMaxSwitchNum()!=null && countIsSwitch>=shop.getMaxSwitchNum()){
|
throw new TipsException("转疗订单已经超过门店设置的最大转疗订单,转疗订单数:"+countIsSwitch+",门店转疗最大数:"+shop.getMaxSwitchNum());
|
}
|
appointment.setIsSwitch(BaseEntity.YES);
|
}
|
}else{
|
//编辑预约判断:预约门店和预约员工门店不一致,判断门店是否还有转疗数量
|
if(!appointment.getShopId().equals(employee.getShopId()) && !oldInfo.getDayStr().equals(appointment.getDayStr())){
|
int countIsSwitch= appointmentV2Service.selectCountIsSwitch(appointment.getDayStr(), appointment.getShopId());
|
log.info("编辑预约:{}{}转疗预约数:{},门店设置最大的转疗数:{}", shop.getName(), appointment.getDayStr(), countIsSwitch, shop.getMaxSwitchNum());
|
if(shop !=null && shop.getMaxSwitchNum() != null && countIsSwitch >= shop.getMaxSwitchNum()){
|
throw new TipsException("转疗订单已经超过门店设置的最大转疗订单,转疗订单数:"+countIsSwitch+",门店转疗最大数:"+shop.getMaxSwitchNum());
|
}
|
appointment.setIsSwitch(BaseEntity.YES);
|
}
|
}
|
}
|
|
//活动日
|
public ActivityDay getActivityDay(String shopId, String dayStr, String doctorId, String [] projectIdsArr){
|
|
Map<String, Object> map = new HashMap<>();
|
SqlSentence sqlSentence = new SqlSentence();
|
|
//查询当天是否有活动日
|
map.put("isDel", BaseEntity.NO);
|
map.put("shopId", shopId);
|
map.put("dayStr", dayStr);
|
sqlSentence.setM(map);
|
sqlSentence.setSqlSentence("select * from activity_day where isDel = #{m.isDel} and shopId = #{m.shopId} and dayStr = #{m.dayStr}");
|
ActivityDay activityDay = commonService.selectOne(ActivityDayMapper.class, sqlSentence);
|
|
if(activityDay == null){
|
return activityDay;
|
}
|
|
//判断选择医生是否符合
|
boolean isDoctor = true;
|
//类型为指定医生时
|
if(activityDay.getType() == ActivityDay.TYPE_APPOINT_DOCTOR){
|
isDoctor = activityDay.getDoctorIds().indexOf(doctorId) != -1;
|
}
|
|
boolean isProject = true;
|
if(isDoctor == true){
|
//判断选择项目是否符合
|
for(String projectId : projectIdsArr){
|
//某个项目不符合时,直接返回false
|
if(activityDay.getProjectIds().indexOf(projectId) == -1){
|
isProject = false;
|
break;
|
}
|
}
|
}
|
|
|
boolean isOk = true;
|
if(isDoctor && isProject){
|
sqlSentence.setSqlSentence("isDel = #{m.isDel} and shopId = #{m.shopId} and activityDayId = #{m.activityDayId} and status = #{m.status} ");
|
map.put("status", Appointment.STATUS_SUC);
|
map.put("activityDayId", activityDay.getId());
|
int count = commonService.selectCount(AppointmentMapper.class, sqlSentence);
|
//判断预约人数是否超过可接待人数
|
if(count >= activityDay.getNumber()){
|
isOk = false;
|
}
|
}else{
|
//都不符合时提示或者下一天
|
isOk = false;
|
}
|
|
//符合条件,且在活动日时间段时,关联活动日id
|
if(isOk == false){
|
activityDay = null;
|
}
|
return activityDay;
|
}
|
|
//获取周日期
|
private Date getWeekDate(Date st){
|
//周,取当前周一
|
Calendar ca = Calendar.getInstance();
|
ca.setTime(st);
|
int dayOfWeek = ca.get(Calendar.DAY_OF_WEEK);
|
if(dayOfWeek == 1) {
|
ca.add(Calendar.DAY_OF_YEAR, -6);
|
}else{
|
ca.add(Calendar.DAY_OF_YEAR, 2 - dayOfWeek);
|
}
|
return ca.getTime();
|
}
|
|
//检测用户创建预约
|
public void checkUserAdd(Integer addMode, String doctorId, Date startTime, Date endTime){
|
|
//非CRM自助预约跳过
|
if(addMode != Appointment.ADD_MODE_CRM_SELF){
|
return;
|
}
|
|
SqlSentence sqlSentence = new SqlSentence();
|
Map<String, Object> values = new HashMap<>();
|
sqlSentence.setM(values);
|
values.put("doctorId", doctorId);
|
values.put("startTime", DateUtil.formatDate_2(startTime));
|
values.put("endTime", DateUtil.formatDate_2(endTime));
|
sqlSentence.setSqlSentence(" select count(1) from appointment where isDel = 0 and status = 1 and startTime = #{m.startTime} and endTime = #{m.endTime} ");
|
int count = commonService.selectCountSql(AppointmentMapper.class, sqlSentence);
|
if(count > 0){
|
throw new TipsException("非常抱歉!\n" + DateUtil.formatDate(startTime, "MM月dd HH:mm - ") + DateUtil.formatDate(endTime, "HH:mm") + " 预约时间已被预约\n请返回重新选择时间。");
|
}
|
|
}
|
|
//
|
// /** CRM预约(CRM的再升美学预约) */
|
// @RequestMapping("/crm/app")
|
// public Result crmApp(@RequestBody(required = false) AppointmentCrmAddDto dto) {
|
//
|
// if (dto == null) {
|
// throw new PlatTipsException(PlatformCode.ERROR_TIPS, "请求参数为空!");
|
// }
|
//
|
// if(dto.getHandleType() == null){
|
// throw new PlatTipsException(PlatformCode.ERROR_TIPS, "处理类型不能为空!");
|
// }
|
//
|
// Appointment appointment = null;
|
// //判断处理类型处理类型(1新增2编辑3取消)
|
// if(dto.getHandleType() == 2 || dto.getHandleType() == 3){
|
// if(StringUtils.isEmpty(dto.getAppointmentId())){
|
// throw new PlatTipsException(PlatformCode.ERROR_TIPS, "预约标识不能为空!");
|
// }
|
//
|
// appointment = commonService.selectOneByKey(AppointmentMapper.class, dto.getAppointmentId());
|
// if(appointment == null){
|
// throw new PlatTipsException(PlatformCode.ERROR_TIPS, "查询不到预约信息!");
|
// }
|
//
|
// //如果处理类型为取消,则直接调用取消逻辑然后返回
|
// if(dto.getHandleType() == 3){
|
// appointmentService.cancel(appointment, dto.getRemark(), Appointment.CANCEL_TYPE_CRM_USER, null);
|
// return Result.success();
|
// }
|
// }
|
//
|
// if(StringUtils.isEmpty(dto.getUserId())){
|
// throw new PlatTipsException(PlatformCode.ERROR_TIPS, "用户标识为空!");
|
// }
|
//
|
// if(StringUtils.isEmpty(dto.getShopId())){
|
// throw new PlatTipsException(PlatformCode.ERROR_TIPS, "门店标识为空!");
|
// }
|
//
|
// if(StringUtils.isEmpty(dto.getDoctorId())){
|
// throw new PlatTipsException(PlatformCode.ERROR_TIPS, "医生标识为空!");
|
// }
|
//
|
// if(StringUtils.isEmpty(dto.getStartTime())){
|
// throw new PlatTipsException(PlatformCode.ERROR_TIPS, "开始时间为空!");
|
// }
|
//
|
// User user = commonService.selectOneByKeyBlob(UserMapper.class, dto.getUserId());
|
// if (user == null) {
|
// throw new PlatTipsException(PlatformCode.ERROR_TIPS, "找不到用户信息!");
|
// }
|
//
|
// Shop shop = commonService.selectOneByKeyBlob(ShopMapper.class, dto.getShopId());
|
// if (shop == null) {
|
// throw new PlatTipsException(PlatformCode.ERROR_TIPS, "找不到门店信息!");
|
// }
|
//
|
// Employee employee = commonService.selectOneByKeyBlob(EmployeeMapper.class, dto.getDoctorId());
|
// if (employee == null) {
|
// throw new PlatTipsException(PlatformCode.ERROR_TIPS, "找不到医生信息!");
|
// }
|
//
|
// //目前写死一个项目
|
// SystemParameter sp = systemParameterService.selectOneByName(SystemParameter.KEY_CRM_APPOINTMENT_PROJECT_ID);
|
// if(sp == null || StringUtils.isEmpty(sp.getParamValue())){
|
// throw new PlatTipsException(PlatformCode.ERROR_TIPS, "还未配置项目信息!");
|
// }
|
//
|
// Project project = commonService.selectOneByKey(ProjectMapper.class, sp.getParamValue());
|
// if(project == null){
|
// throw new PlatTipsException(PlatformCode.ERROR_TIPS, "找不到项目信息!");
|
// }
|
//
|
// if(project == null || project.getIsDel() == BaseEntity.YES || project.getIsUp() == BaseEntity.NO)
|
// {
|
// throw new PlatTipsException(PlatformCode.ERROR_TIPS, "找不到项目或者项目下架!");
|
// }
|
//
|
// //组装json数组
|
// JSONArray arr = new JSONArray();
|
// JSONObject temp = new JSONObject();
|
// temp.put("id", project.getId());
|
// temp.put("num", 1);
|
// temp.put("isLifeBeauty", project.getIsLifeBeauty());
|
// temp.put("name", project.getName());
|
// temp.put("palsyDuration", project.getPalsyDuration());
|
// temp.put("isPalsy", project.getPalsyDuration() > 0 ? 1 : 0);
|
// temp.put("useDuration", project.getUseDuration());
|
// arr.add(temp);
|
//
|
// String [] projectIdsArr = new String[arr.size()];
|
// String [] projectNamesArr = new String[arr.size()];
|
// Map<String, Integer> pNumMap = new HashMap<>();
|
// Map<String, Integer> pZlMap = new HashMap<>();
|
// String id = null;
|
// int num = 0;
|
// int zlTime = 0;
|
//
|
//
|
// List<AppointmentProject> apList = new ArrayList<>();
|
// LinkedHashMap<String, ProjectVo> pMap = new LinkedHashMap<>();
|
// for(int i = 0; i < arr.size(); i ++)
|
// {
|
// temp = arr.getJSONObject(i);
|
// id = temp.getString("id");
|
// num = temp.getIntValue("num");
|
// if(StringUtils.isEmpty(id) || num <= 0)
|
// {
|
// throw new PlatTipsException(PlatformCode.ERROR_TIPS, "请选择正确项目和数量");
|
// }
|
// project = commonService.selectOneByKey(ProjectMapper.class, id);
|
// if(project == null || project.getIsDel() == BaseEntity.YES || project.getIsUp() == BaseEntity.NO)
|
// {
|
// throw new PlatTipsException(PlatformCode.ERROR_TIPS, "找不到项目或者项目下架");
|
// }
|
//// //获取最大的术前准备时间
|
//// if(project.getReadyDuration() > sqTime){
|
//// sqTime = project.getReadyDuration();
|
//// }
|
// pNumMap.put(id, num);
|
// //判断治疗时间等于0,则默认5分钟
|
// pZlMap.put(id, project.getUseDuration() == null ? 0 : project.getUseDuration());
|
// pMap.put(id, new ProjectVo(project, num, dto.getShopId()));
|
// pMap.get(id).setZlTime(project.getUseDuration() / 60);
|
// projectIdsArr[i] = id;
|
// projectNamesArr[i] = project.getName();
|
// apList.add(new AppointmentProject(id, num));
|
// //治疗时间(分钟) = 项目使用时长(秒) / 60
|
// zlTime += project.getUseDuration() / 60;
|
// }
|
//
|
// SqlSentence sqlSentence = new SqlSentence();
|
// Map<String, Object> values = new HashMap<>();
|
// sqlSentence.setM(values);
|
//
|
// AppointmentInfo appointmentInfo = new AppointmentInfo();
|
// if(appointment == null){
|
// appointment = new Appointment();
|
// }
|
// appointment.setStatus(Appointment.STATUS_SUC);
|
// appointment.setSourceId(dto.getSourceId());
|
// appointment.setShopId(dto.getShopId());
|
// appointment.setDoctorId(dto.getDoctorId());
|
// appointment.setUserId(dto.getUserId());
|
// //项目信息
|
// appointment.setProjectJson(arr.toJSONString());
|
// appointment.setProjectIds(org.apache.commons.lang.StringUtils.join(projectIdsArr,","));
|
// appointment.setProjectNames(org.apache.commons.lang.StringUtils.join(projectNamesArr,","));
|
// //时间信息
|
// appointment.setStartTime(DateUtil.parseString_1(dto.getStartTime()));
|
// appointment.setEndTime(DateUtil.parseString_1(dto.getEndTime()));
|
// appointment.setDayStr(DateUtil.formatDate(appointment.getStartTime()));
|
// //周字符串
|
// Calendar ca = Calendar.getInstance();
|
// ca.setTime(appointment.getStartTime());
|
// int dayOfWeek = ca.get(Calendar.DAY_OF_WEEK);
|
// if(dayOfWeek == 1)
|
// {
|
// ca.add(Calendar.DAY_OF_YEAR, -6);
|
// }else{
|
// ca.add(Calendar.DAY_OF_YEAR, 2 - dayOfWeek);
|
// }
|
// appointment.setWeekStr(DateUtil.formatDate(ca.getTime()));
|
// appointment.setMonthStr(appointment.getDayStr().substring(0, 6));
|
// //所属顾问,使用用户所属顾问
|
// appointment.setCorpUserId(user.getHisCorpUserId());
|
// //创建人信息
|
// appointment.setCreateManId(user.getId());
|
// appointment.setCreateManName(user.getName());
|
// appointment.setCreateManType(Appointment.CREATE_MAN_TYPE_USER);
|
// //默认就诊类型:医美
|
// appointment.setVisitType("医美");
|
// //备注
|
// appointment.setRemark(dto.getRemark());
|
// //新增模式
|
// appointment.setAddMode(Appointment.ADD_MODE_CRM_CREATE);
|
//
|
// //
|
// appointment.setComDuration(0);
|
// appointment.setDocComDuration(0);
|
// appointment.setReadyDuration(0);
|
// appointment.setProDuration(0);
|
// appointment.setPalsyDuration(0);
|
// appointment.setTreatDuration(zlTime);
|
// appointment.setDoctorZlDuration(zlTime);
|
//
|
// //总时长 = 面诊 + 沟通 + 敷麻 + 术前 + 准备等待 + 治疗
|
// int duration = appointment.getDocComDuration() + appointment.getComDuration() + appointment.getPalsyDuration() + appointment.getReadyDuration() + appointment.getWaitDuration() + appointment.getTreatDuration();
|
// appointment.setDuration(duration);
|
//
|
// //获取出医生的治疗时间记录
|
// JSONArray zlTimeJson = AppAutoMateV5Util.handleDoctorZlTime(pMap, appointment.getStartTime());
|
// appointmentInfo.setZlTimeJson(zlTimeJson.toString());
|
// List<DoctorTime> doctorTimeList = AppointmentV2Util.getDoctorZlTime(zlTimeJson.toString(), appointment.getShopId(), appointment.getDoctorId(), appointment.getDayStr(), appointment.getMonthStr());
|
//
|
//
|
// //新增时
|
// if(StringUtils.isEmpty(appointment.getId())){
|
//
|
// //冗余用户信息
|
// appointmentInfo.setUserStatus(user.getUserStatus());
|
// appointmentInfo.setUserStatusCn(UserStatusConstants.getName(user.getUserStatus()));
|
// appointmentInfo.setUserInternetCorpUserId(user.getInternetCorpUserId());
|
// appointmentInfo.setUserInternetCorpUserName(CommonQueryUtil.getEmployeeName(user.getInternetCorpUserId(), commonService));
|
// appointmentInfo.setUserConsultantId(user.getHisCorpUserId());
|
// appointmentInfo.setUserConsultantName(CommonQueryUtil.getEmployeeName(user.getHisCorpUserId(), commonService));
|
// appointmentInfo.setUserShopId(user.getShopId());
|
// appointmentInfo.setUserShopName(CommonQueryUtil.getShopName(user.getShopId(), commonService));
|
// appointmentInfo.setUserLevel(user.getUserLevel());
|
// appointmentInfo.setMemberLevelId(user.getMemberLevelId());
|
//
|
// //根据用户角色信息,获取对应可使用预约类型,多个取第一个
|
// net.sf.json.JSONArray appTypeArr = AppointmentListUtil.userToAppType(dto.getUserId(), commonService);
|
// if(appTypeArr == null || appTypeArr.size() < 1){
|
// throw new PlatTipsException(PlatformCode.ERROR_TIPS, "没有对应预约类型!");
|
// }
|
// appointment.setAppType(appTypeArr.getInt(0));
|
// }
|
//
|
// //添加预约
|
// if(dto.getHandleType() == 1){
|
// appointmentService.crmAdd(appointment, apList, doctorTimeList, null, appointmentInfo);
|
// }else if(dto.getHandleType() == 2){
|
// appointmentService.crmEdit(appointment, appointmentInfo, 0, doctorTimeList, apList, null, null);
|
// }
|
//
|
//
|
// JSONObject data = new JSONObject();
|
// data.put("appointmentId", appointment.getId());
|
//
|
// return Result.success(data);
|
// }
|
|
}
|