import { Injectable } from "@angular/core";
import { HttpClient, HttpHeaders } from "@angular/common/http";

import host from "../../assets/js/http";
import { Observable, of } from "rxjs";
import { AES, mode, pad, enc } from "crypto-js";
import { MarkingService } from './marking.service';

@Injectable({
  providedIn: "root",
})
export class MainService {
  constructor(private http: HttpClient, private markingService: MarkingService) {}

  headers = new HttpHeaders({
    "Content-Type": "application/json",
    "Cache-Control": "no-cache",
  });
  exportHeader = new HttpHeaders().set("Accept", "*/*"); //导出excel表使用
  // 单点登录
  singleSignOnLogin(data): any {
    return this.http.post(host.host + "/auth/portalLogin", data, {
      headers: this.headers,
    });
  }
  //aes加密
  encryptByEnAES(data: string): string {
    data = enc.Utf8.parse(data);
    let Key = enc.Utf8.parse('Aes2Util666AQWER');
    let tmpAES = AES.encrypt(data, Key, {
      mode: mode.ECB,
      padding: pad.Pkcs7,
    });
    return tmpAES.toString();
  }
  // 登录
  login(name: string, pwd: string, captcha: string, captchaId: string): any {
    let data:any = {
      username: name,
      password: pwd,
			captcha: captcha,
			captchaId: captchaId,
      type: "PC",
    };
    data = {
      k: this.encryptByEnAES(JSON.stringify(data))
    };
    return this.http.post(host.host + "/auth/login", data, {
      headers: this.headers,
    });
  }
  // 登出
  logOut(): any {
    return this.http.delete(host.host + "/auth/logout2", {
      headers: this.headers,
    });
  }

  // 修改密码
  upPwd(data): any {
    return this.http.post(host.host + "/auth/uppwd", data, {
      headers: this.headers,
    });
  }
  // 字典表
  cachedDictionary = {}; //缓存到内存的字典
  getDictionary(type, key, flag = false): any {
    const data = {
      type: type,
      key: key,
    };
    console.log(this.cachedDictionary, "------------db");
    if (flag) {
      //特殊情况下处理，flag是true
      return this.http.post(host.host + "/common/common/getDictionary", data, {
        headers: this.headers,
      });
    } else if (this.cachedDictionary[key]) {
      return new Observable((observer) => {
        observer.next(this.cachedDictionary[key]);
      });
    } else {
      return new Observable((observer) => {
        this.http
          .post(host.host + "/common/common/getDictionary", data, {
            headers: this.headers,
          })
          .subscribe((result) => {
            this.cachedDictionary[key] = result;
            observer.next(result);
          });
      });
    }
  }
  //清除字典表缓存
  clearDictionary() {
    this.cachedDictionary = {};
    console.log(this.cachedDictionary, "------clearDb");
  }
  // 列表搜索（通用）
  getFetchDataList(type, target, data): any {
    return this.http.post(
      host.host + "/" + type + "/fetchDataList/" + target,
      data,
      { headers: this.headers }
    );
  }

  // 调度台 获取配送人员信息
  getSerInfo(type, data): any {
    return this.http.post(host.host + "/ser/" + type, data, {
      headers: this.headers,
    });
  }

  // 通用操作data信息（新增/更新/删除）//coop:操作类型addData:新增，updData更新，rmvData删除
  coopData(coop, type, data): any {
    return this.http.post(host.host + "/data/" + coop + "/" + type, data, {
      headers: this.headers,
    });
  }

  // 清空药品
  coopDataM(coop, data): any {
    return this.http.post(host.host + "/" + coop, data, {
      headers: this.headers,
    });
  }

  // 通用操作user data信息（新增/更新/删除）//coop:操作类型addData:新增，updData更新，rmvData删除
  coopUserData(coop, type, data): any {
    return this.http.post(host.host + "/user/data/" + coop + "/" + type, data, {
      headers: this.headers,
    });
  }
  // 获取院区user信息
  getHosUser(type, id): any {
    return this.http.get(host.host + "/user/data/" + type + "/" + id, {});
  }

  // 通用操作configuration信息 有操作类型（新增/更新/删除）//coop:操作类型addData:新增，updData更新，rmvData删除
  coopTypeConfig(coop, type, data): any {
    return this.http.post(
      host.host + "/configuration/" + coop + "/" + type,
      data,
      { headers: this.headers }
    );
  }
  // 通用操作configuration信息（新增/更新/删除）
  coopConfig(type, data): any {
    return this.http.post(host.host + "/configuration/" + type, data, {
      headers: this.headers,
    });
  }

	// 通用操作configuration信息 有操作类型（新增/更新/删除）//coop:操作类型addData:新增，updData更新，rmvData删除
	apiPublicData(coop, type, data): any {
	  return this.http.post(
	    host.host + "/data/" + coop + "/" + type,
	    data,
	    { headers: this.headers }
	  );
	}

  // 权限相关
  getPermission(type): any {
    return this.http.get(host.host + "/permission/roleMenu/" + type, {
      headers: this.headers,
    });
  }
  // fetchData查看详情
  getFetchData(type, info, id): any {
    return this.http.get(
      host.host + "/" + type + "/fetchData/" + info + "/" + id,
      { headers: this.headers }
    );
  }

  // 自定义请求 post
  postCustom(type, info, data): any {
    return this.http.post(host.host + "/" + type + "/" + info, data, {
      headers: this.headers,
    });
  }

  // 自定义请求 post-导出
  postExportCustom(type, info, data): any {
    return this.http.post(host.host + "/" + type + "/" + info, data, {
      headers: this.exportHeader,
      responseType: "arraybuffer",
    });
  }

  // 科室二维码打印flag=1
  postCustomCode(type, info, data): any {
    return this.http.post(host.host + "/" + type + "/" + info + "/1", data, {
      headers: this.headers,
    });
  }

  // 自定义请求 get
  getCustom(type, info): any {
    return this.http.get(host.host + "/" + type + "/" + info, {
      headers: this.headers,
    });
  }
  // 调度台-分派工单
  assignWorker(data, type): any {
    return this.http.post(host.host + "/workerOrder/" + type, data, {
      headers: this.headers,
    });
  }

  // 调度台-删除工单
  delOrder(id): any {
    return this.http.get(host.host + "/workerOrder/delWorkOrder/" + id, {
      headers: this.headers,
    });
  }
  // 工单列表-删除工单
  delOrders(ids): any {
    return this.http.post(
      host.host + "/workerOrder/delWorkOrders",
      { ids },
      { headers: this.headers }
    );
  }

  // 调度台工单相关
  coopWorkerOrder(type, data): any {
    return this.http.post(host.host + "/workerOrder/" + type, data, {
      headers: this.headers,
    });
  }

  // 调度台-工单历史记录
  getWorkOrderLog(id): any {
    return this.http.get(host.host + "/ser/fetchWorkOrderLog/" + id, {
      headers: this.headers,
    });
  }

  // 综合报表
  postReportCount(type, data): any {
    return this.http.post(host.host + "/report/orderCount/" + type, data, {
      headers: this.headers,
    });
  }

  // 报表导出
  exportReport(type, data): any {
    return this.http.post(host.host + "/report/export/" + type, data, {
      headers: this.exportHeader,
      responseType: "arraybuffer",
    });
  }

  dataExport(type, data): any {
    return this.http.post(host.host + "/data/export/" + type, data, {
      headers: this.exportHeader,
      responseType: "arraybuffer",
    });
  }
  //新增/编辑轮巡计划
  addRoundRobin(type: string, data: any): any {
    return this.http.post(host.host + "/orderPlan/" + type, data, {
      headers: this.headers,
    });
  }
  //删除轮巡计划
  delRoundRobin(id): any {
    return this.http.get(host.host + "/orderPlan/deletePlan/" + id, {
      headers: this.headers,
    });
  }
  //启用/停用轮巡计划
  switchRoundRobin(isSwitch, id): any {
    return this.http.get(
      `${host.host}/orderPlan/activePlan/${isSwitch}/${id}`,
      { headers: this.headers }
    );
  }
  //新增/编辑快捷建单
  addShortcutBuildOrders(type: string, data: any): any {
    return this.http.post(host.host + "/api/" + type + "/quickOrder", data, {
      headers: this.headers,
    });
  }
  //删除快捷建单
  delShortcutBuildOrders(id): any {
    return this.http.post(host.host + "/api/rmvData/quickOrder", [id], {
      headers: this.headers,
    });
  }
  // 快捷建单二维码批量打印
  printShortcutBuildOrders(idArr): any {
    return this.http.post(host.host + "/api/orderCodes", idArr, {
      headers: this.headers,
    });
  }
  //护士端返回二维码信息,flag=0，动态二维码
  getDeptCode(idArr) {
    return this.http.post(host.host + "/dept/deptCodes/0", idArr, {
      headers: this.headers,
    });
  }
  //药房端打印二维码的接口
  printRequisition(idArr) {
    return this.http.post(host.host + "/drugsBag/printRequisition", idArr, {
      headers: this.headers,
    });
  }
  //药房端待打印变为待配药接口
  changeToDispensing(idArr, name) {
    return this.http.post(
      host.host + "/drugsBag/changeToDispensing/" + name,
      idArr,
      { headers: this.headers }
    );
  }
  //新建工单->获取新建类型
  getAutoWorkTypes(hosId) {
    return this.http.get(host.host + "/ser/getAutoWorkTypes/" + hosId, {
      headers: this.headers,
    });
  }
  //服务台新建工单—调度台建单获取起点科室或者终点科室列表
  getdeptList(taskTypeId, applyDeptId?, patientCode?, startTime?, endTime?) {
    return this.http.post(
      host.host + "/ser/getdeptList",
      { taskTypeId, patientDeptId: applyDeptId || undefined,  patientCode: patientCode || undefined, startTime, endTime },
      { headers: this.headers }
    );
  }
  //服务台新建工单—调度台建单获取患者
  getPatientList(data) {
    return this.http.post(host.host + "/ser/getPatientInfo", data, {
      headers: this.headers,
    });
  }
  //服务台新建工单—调度台建单获取起点科室或者终点科室列表
  buildOrder(data) {
    return this.http.post(host.host + "/ser/buildOrder", data, {
      headers: this.headers,
    });
  }
  //获取当前用户信息
  getCurrentUser1() {
    return this.http.get(host.host + "/user/data/getCurrentUser", {
      headers: this.headers,
    });
  }
  //获取通话记录音频地址
  getCallLogPath(data) {
    return this.http.post(host.host + "/callLog/getRecordByPath", data, {
      headers: this.headers,
    });
  }
  //根据工作分配和人员id获取科室信息
  getDeptByUser(data) {
    return this.http.post(host.host + "/api/getDeptByUser", data, {
      headers: this.headers,
    });
  }
  //根据工作分配和分组id获取科室信息
  getDeptByGroup(data) {
    return this.http.post(host.host + "/api/getDeptByGroup", data, {
      headers: this.headers,
    });
  }
  //微信配置修改
  changeWechatConfig(data) {
    return this.http.post(
      host.host + "/simple/data/addData/wechatConfig",
      data,
      { headers: this.headers }
    );
  }
  //系统配置修改
  changeSysConfig(data) {
    return this.http.post(
      host.host + "/simple/data/addListData/systemConfiguration",
      data,
      { headers: this.headers }
    );
  }
  //数据字典楼栋保存接口
  saveBuildingList(data) {
    return this.http.post(
      host.host + "/simple/data/addListData/building",
      data,
      { headers: this.headers }
    );
  }
  //数据字典楼栋删除接口
  delBuildingList(data) {
    return this.http.post(host.host + "/simple/data/rmvData/building", data, {
      headers: this.headers,
    });
  }
  //数据字典楼层保存接口
  saveFloorList(data) {
    return this.http.post(host.host + "/simple/data/addListData/floor", data, {
      headers: this.headers,
    });
  }
  //数据字典楼层保存接口
  delFloorList(data) {
    return this.http.post(host.host + "/simple/data/rmvData/floor", data, {
      headers: this.headers,
    });
  }
  //simple增删改查,addData新增,addListData批量新增
  simplePost(coop, type, data): any {
    return this.http.post(
      host.host + "/simple/data/" + coop + "/" + type,
      data,
      { headers: this.headers }
    );
  }
  //api增删改查
  apiPost(coop, type, data): any {
    return this.http.post(
      host.host + "/api/" + coop + "/" + type,
      data,
      { headers: this.headers }
    );
  }
	//data增删改查
	dataPost(coop, type, data): any {
	  return this.http.post(
	    host.host + "/data/" + coop + "/" + type,
	    data,
	    { headers: this.headers }
	  );
	}
  //获取工单详情里的历史记录
  getWorkOrderRecord(data): any {
    return this.http.post(host.host + "/workerOrder/getWorkOrderRecord", data, {
      headers: this.headers,
    });
  }
  //刷新字典缓存
  refreshDic(): any {
    return this.http.post(
      host.host + "/common/common/refreshCache",
      {},
      { headers: this.headers }
    );
  }
  //调度台建单获取可搜索的任务类型列表
  getTaskTypeBySearchKey(data): any {
    return this.http.post(host.host + "/ser/getTaskTypeBySearchKey", data, {
      headers: this.headers,
    });
  }
  //调度台建单获取可搜索的任务类型列表-统计备注
  getTaskTypeCountRemarkList(data): any {
    return this.http.post(host.host + "/ser/getTaskTypeCountRemarkList", data, {
      headers: this.headers,
    });
  }
  //切换院区
  changeHospital(data): any {
    return this.http.post(host.host + "/auth/changeHospital", data, {
      headers: this.headers,
    });
  }
  //刷新缓存
  refreshTaskType(): any {
    return this.http.get(host.host + "/ser/refreshTaskType", {
      headers: this.headers,
    });
  }
  //楼栋配置保存接口
  saveBuildings(data) {
    return this.http.post(
      host.host + "/simple/data/addListData/workOrderGradeBuilding",
      data,
      { headers: this.headers }
    );
  }
  //删除接口
  delBuildings(data) {
    return this.http.post(
      host.host + "/simple/data/rmvData/workOrderGradeBuilding",
      data,
      { headers: this.headers }
    );
  }
  //检查信息,患者信息
  listMsgByMain(type, data) {
    return this.http.post(host.host + "/nurse/" + type, data, {
      headers: this.headers,
    });
  }
  //院区系统配置修改
  changeHospitalSysConfig(data) {
    return this.http.post(
      host.host + "/simple/data/addListData/hospitalConfig",
      data,
      { headers: this.headers }
    );
  }
  //删除用户（包含企业微信用户）
  rmvDataAndWeChatNum(data, flag) {
    return this.http.post(
      host.host + "/user/data/rmvDataAndWeChatNum/" + flag,
      data,
      {
        headers: this.headers,
      }
    );
  }
  //数据核对
  infoSearch(type, id) {
    return this.http.get(host.host + "/testData/view/" + type + "/" + id, {
      headers: this.headers,
    });
  }
  //数据核对-原始数据
  queryDataSource(data = {}) {
    return this.http.post(host.host + "/testData/queryDataSource", data, {
      headers: this.headers,
    });
  }
  // 更新,新增，删除检查类型设置
  upDictionary(data) {
    return this.http.post(host.host + "/common/common/upDictionary", data, {
      headers: this.headers,
    });
  }
  // 护士端定时预约工单立即执行
  executeNow(id, data) {
    return this.http.post(host.host + "/api/directStartOrder/" + id, data, {
      headers: this.headers,
    });
  }
  //定时下班列表立即执行
  executeNowClassesJob(data) {
    return this.http.post(host.host + "/configuration/directOffDuty", data, {
      headers: this.headers,
    });
  }
  //轮巡计划列表立即执行
  executeNowOrderPlan(id) {
    return this.http.get(host.host + "/orderPlan/directOrderPlan/" + id, {
      headers: this.headers,
    });
  }
  //查报修列表
  listWxIncident(data) {
    return this.http.post(host.host + "/itsm/fetchDataList/incident", data, {
      headers: this.headers,
    });
  }
  //获取附件图片
  listAttachment(type, id) {
    return this.http.get(host.host + "/itsm/common/listAttachment/" + type + "/" + id, {
      headers: this.headers,
    });
  }
  //查列表
  fetchListBx(type, data) {
    return this.http.post(host.host + "/itsm/fetchDataList/" + type, data, {
      headers: this.headers,
    });
  }
  //查单个
  fetchDataBx(target, id) {
    return this.http.post(host.host + "/itsm/fetchData/" + target + "/" + id,{}, {
      headers: this.headers,
    });
  }
  //提交报修
  addWxIncident(data) {
    return this.http.post(host.host + "/itsm/addWxIncident", data, {
      headers: this.headers,
    });
  }
  //获取工单单号
  wxbx(data) {
    return this.http.post(host.host + "/itsm/restful/sj", data, {
      headers: this.headers,
    });
  }
  //获取ITSM字典
  getDictionaryByITSM(data) {
    return this.http.post(host.host + "/itsm/common/getDictionary", data, {
      headers: this.headers,
    });
  }
  //报修评价
  degree(data) {
    return this.http.post(host.host + "/itsm/bpm/degree", data, {
      headers: this.headers,
    });
  }
  //汇总单
  querySummaryDoc(data) {
    return this.http.post(host.host + "/itsm/bpm/querySummaryDoc", data, {
      headers: this.headers,
    });
  }
  //修改用户
  saveUser(data) {
    return this.http.post(host.host + "/itsm/user/saveUser", data, {
      headers: this.headers,
    });
  }
  //复制院区
  copyHosTaskType(data) {
    return this.http.post(host.host + "/api/copyHosTaskType", data, {
      headers: this.headers,
    });
  }
  //药房端2统计数据
  getDrugsBagStateCount(data) {
    return this.http.post(host.host + "/ser/getDrugsBagStateCount", data, {
      headers: this.headers,
    });
  }
   // 标本视图查询列表接口
   specimenView2(data): any {
    return this.http.post(
      host.host + "/nurse/specimenView2",
      data,
      { headers: this.headers }
    );
  }
  //问卷发布
  managerQuestionnaire(data) {
    return this.http.post(
      host.host + "/user/data/managerQuestionnaire",
      data,
      {
        headers: this.headers,
      }
    );
  }
  //问卷预览
  managerQuestionnairePreview(data,token) {
    return this.http.post(
      host.host + "/api/survey/" + token,
      data,
      {
        headers: this.headers,
      }
    );
  }
  //问卷提交答案
  surveyCommit(data) {
    return this.http.post(
      host.host + "/api/survey/commit",
      data,
      {
        headers: this.headers,
      }
    );
  }
  //查询回收数据
  listQuestionnaire(data) {
    return this.http.post(
      host.host + "/user/data/listQuestionnaire",
      data,
      {
        headers: this.headers,
      }
    );
  }
  //查询楼栋核酸
  getNucleicAcidBuildingSummary(data) {
    return this.http.post(
      host.host + "/workerOrder/nucleicAcidBuildingSummary",
      data,
      {
        headers: this.headers,
      }
    );
  }
  //打印楼栋核酸
  printNucleicAcid(data) {
    return this.http.post(
      host.host + "/api/printNucleicAcid",
      data,
      {
        headers: this.headers,
      }
    );
  }
  //获取附件-通用
  getPreviewImage(type, id) {
    return this.http.get(host.host + "/common/common/listAttachment/"+ type +"/" + id, {
      headers: this.headers,
    });
  }
  //补充打印楼栋核酸
  supplementPrintNucleicAcid(data) {
    return this.http.post(
      host.host + "/api/supplementPrintNucleicAcid",
      data,
      {
        headers: this.headers,
      }
    );
  }
  //查看工单里的血制品信息
  checkData(data) {
    return this.http.post(
      host.host + "/transflow/checkData",
      data,
      {
        headers: this.headers,
      }
    );
  }
  //陪检配置保存接口
  saveInspections(data) {
    return this.http.post(
      host.host + "/simple/data/addListData/workOrderInspectScore",
      data,
      { headers: this.headers }
    );
  }
  // 重置密码
  resetpwd(id): any {
    return this.http.get(host.host + "/auth/resetpwd/" + id, {});
  }
  // api接口
  apiPostAll(type, data) {
    return this.http.post(
      host.host + "/api/" + type,
      data,
      { headers: this.headers }
    );
  }
  //手动创建手术工单
  createOrTakeOrder(data) {
    return this.http.post(
      host.host + "/transflow/createOrTakeOrder",
      data,
      {
        headers: this.headers,
      }
    );
  }
  //手动创建手术工单-送回病房
  createRemandOrder(data) {
    return this.http.post(
      host.host + "/transflow/createRemandOrder",
      data,
      {
        headers: this.headers,
      }
    );
  }
  // 获取logo和title
  getSysNameAndLogo(hosId): any {
    return this.http.get(host.host + "/auth/getSysNameAndLogo" + (hosId ? '?hosId=' + hosId : ''), {});
  }

  //获取启动中的工作分配方案
  getUserWorkDept(data) {
    return this.http.post(
      host.host + "/auth/getUserWorkDept",
      data,
      {
        headers: this.headers,
      }
    );
  }
  //上下班
  onOrOffLine(data) {
    return this.http.post(
      host.host + "/auth/onOrOffLine",
      data,
      {
        headers: this.headers,
      }
    );
  }

  // 科室检查率统计
  postReportDept(type, data): any {
    return this.http.post(host.host + "/report/dept/" + type, data, {
      headers: this.headers,
    });
  }

  // 楼栋检查率统计
  postReportBuilding(type, data): any {
    return this.http.post(host.host + "/report/building/" + type, data, {
      headers: this.headers,
    });
  }

  // 楼栋检查统计
  postReportBuild(type, data): any {
    return this.http.post(host.host + "/report/build/" + type, data, {
      headers: this.headers,
    });
  }

  // 获取检验项目列表
  specimenCount(data): any {
    return this.http.post(host.host + "/api/specimenDesc/specimenCount", data, {
      headers: this.headers,
    });
  }

  // 被服洗涤-视图
  clothesWashing(data, type): any {
    return this.http.post(host.host + "/clothesWashing/" + type, data, {
      headers: this.headers,
    });
  }
  // transflow
  transflow(data, type): any {
    return this.http.post(host.host + "/transflow/" + type, data, {
      headers: this.headers,
    });
  }
  // 打印门诊服务点二维码
  qrcodeCardNo(data): any {
    return this.http.post(host.host + "/patient/qrCode", data, {
      headers: this.headers,
    });
  }
  // 医废-获取重量和袋数
  getWeightAndCount(data): any {
    return this.http.post(host.host + "/medicalWaste/getWeightAndCount", data, {
      headers: this.headers,
    });
  }
  // 医废-出库
  medicalWasteComplete(data): any {
    return this.http.post(host.host + "/medicalWaste/complete", data, {
      headers: this.headers,
    });
  }
  // 模板导出
  exportExcel(model, data): any {
    return this.http.post(host.host + "/user/data/exportExcel/" + model, data, {
      headers: this.exportHeader,
      responseType: "arraybuffer",
    });
  }
  // 巡检相关接口
  inspectionPost(type, data): any {
    return this.http.post(host.host + "/inspection/" + type, data, {
      headers: this.headers,
    });
  }
	// 验证工单问卷二维码是否过期
	verifyPastApi(data): any {
	  return this.http.post(host.host + "/questionnaire/check", data, {
	    headers: this.headers,
	  });
	}
	// 科室发药单打印
	transfusionPrint(model, id): any {
	  return this.http.get(host.host + `/simple/data/fetchData/${model}/${id}`);
	}
	// 科室发药配送建单
	transfusionBuildOrder(data): any {
	  return this.http.post(host.host + "/infusion/solutions/createOrTakeOrder", data, {
	    headers: this.headers,
	  });
	}
	// 发药批次-配置科室删除
	transfusionConfigDeptDel(data): any {
	  return this.http.post(host.host + "/infusion/solutions/remove", data, {
	    headers: this.headers,
	  });
	}
  // 配置中心
	incidentPost(type, data): any {
	  return this.http.post(host.host + "/incident/" + type, data, {
	    headers: this.headers,
	  });
	}
	// 发药批次-配置科室数据
	getConsumeDept(data): any {
	  return this.http.post(host.host + "/infusion/solutions/getConsumeDept", data, {
	    headers: this.headers,
	  });
	}
	//删除附件图片
	removeAttachment(token) {
	  return this.http.post(host.host + `/common/common/removeAttachment/${token}`,{}, {
	    headers: this.headers,
	  });
	}

	// wechat相关-重置token
	refreshToken(type, data): any {
	  return this.http.post(host.host + "/wechat/" + type, data, {
	    headers: this.headers,
	  });
	}

  // 故障工单-获取数量
	getCount(data): any {
	  return this.http.post(host.host + "/flow/incident/list/count", data, {
	    headers: this.headers,
	  });
	}

  // 故障工单-导出
	downDataModel(data): any {
	  return this.http.post(host.host + "/incident/data/downDataModel/incident/3", data, {
	    headers: this.exportHeader,
      responseType: "arraybuffer",
	  });
	}

  // 故障工单-流程操作
	flowPost(type, data): any {
	  return this.http.post(host.host + "/flow/" + type, data, {
	    headers: this.headers,
	  });
	}

  // 查询汇总单
	querySummaryDocNew(data): any {
	  return this.http.post(host.host + "/incident/data/querySummaryDoc", data, {
	    headers: this.headers,
	  });
	}

  // 新增汇总单
	addSummaryDoc(data): any {
	  return this.http.post(host.host + "/incident/data/addSummaryDoc", data, {
	    headers: this.headers,
	  });
	}

  // 返回附件上传url
  returnUploadUrl(type, id): string {
    return `${host.host}/common/common/uploadAttachment/${type}/${id}/${id}`;
  }

  // 返回excel导入url
  returnImportExcelUrl(type): string {
    return `${host.host}/user/data/importExcel/${type}`
  }

  // 设置责任部门
	changeIncidentDuty(data): any {
	  return this.http.post(host.host + "/incident/data/changeIncidentDuty", data, {
	    headers: this.headers,
	  });
	}

  // 下载附件
	downloadAttachment(token): any {
	  return host.host + "/common/common/downloadAttachment/" + token;
	}

	//病理申请单打印
	 pathologyPrint(data) {
	   return this.http.post(host.host + `/pathology/print`, data, {
	     headers: this.headers,
	   });
	 }

	//病理申请单追加打印/全量打印
	 pathologyCheckPrint(type,businessId,data) {
	   return this.http.post(host.host + `/pathology/check/${type}/${businessId}`, data, {
	     headers: this.headers,
	   });
	 }

	// 病例申请单暂存
	pathologyOperation(data,operation) {
	  return this.http.post(host.host + `/pathology/${operation}`, data, {
	    headers: this.headers,
	  });
	}

	// 病理查询标本条码
	pathologyScanCode(data) {
	  return this.http.post(host.host + `/pathology/scanCode`, data, {
	    headers: this.headers,
	  });
	}

	// 工号搜索
	jobSearch(data) {
	  return this.http.post(host.host + `/data/isRepeat`, data, {
	    headers: this.headers,
	  });
	}

	// 标本间获取批次号
	generateBatchNumber() {
	  return this.http.post(host.host + `/pathology/generateBatchNumber/blbatch`, {}, {
	    headers: this.headers,
	  });
	}

	// 标本间获取标本接收信息
	getSpecimenInfo(batchNo,deptId,data) {
	  return this.http.post(host.host + `/pathology/getInfo/${batchNo}/${deptId}`, data, {
	    headers: this.headers,
	  });
	}

	// 标本间标本接收-交接完成
	handoverCompleted(data) {
	  return this.http.post(host.host + `/pathology/handoverCompleted`, data, {
	    headers: this.headers,
	  });
	}

	// 病理科打包
	pathologyPack(data) {
	  return this.http.post(host.host + `/pathology/pack`, data, {
	    headers: this.headers,
	  });
	}

	// 病理科今日接收汇总
	pathologyToday(data) {
	  return this.http.post(host.host + `/pathology/receiveToday`, data, {
	    headers: this.headers,
	  });
	}

	// 大输液-发药批次-发药总量
	drugsGross(batchId) {
	  return this.http.get(host.host + `/infusion/solutions/drugsNum/${batchId}`, {
	    headers: this.headers,
	  });
	}

	// 大输液-发药批次-发药信息
	drugsInfo(data) {
	  return this.http.post(host.host + `/infusion/solutions/dispensing/medicine/details`,data, {
	    headers: this.headers,
	  });
	}

	// 统计分析-陪检统计
	inspectionStatistics(data) {
	  return this.http.post(host.host + `/report/accompanied/inspection`,data, {
	    headers: this.headers,
	  });
	}

	// 调度台工单列表
	orderList(data) {
	  return this.http.post(host.host + `/ser/merge/orderList`,data, {
	    headers: this.headers,
	  });
	}
  // 调度台头部运维分组
	incidentUserTaskCount(data) {
	  return this.http.post(host.host + `/incident/incidentUserTaskCount`,data, {
      headers: this.headers,
	  });
	}
	// 大输液-科室汇总统计
	summaryData(data) {
	  return this.http.post(host.host + `/infusion/solutions/dept/summary`,data, {
	    headers: this.headers,
	  });
	}
	// 获取动态密钥
	getSecretKey(deptId) {
	  return this.http.post(host.host + `/dept/secretKey/${deptId}`,{}, {
	    headers: this.headers,
	  });
	}
  // 根据来电电话查科室
	findPhoneDept(data) {
	  return this.http.post(host.host + `/user/data/findPhoneDept`, data, {
	    headers: this.headers,
	  });
	}
  // 获取细胞学标本
	getCellDictionary(data) {
	  return this.http.post(host.host + `/common/common/getDictionary`,data, {
	    headers: this.headers,
	  });
	}
	// 门诊病理采样端单点登录查询
	registerOutpatient(name, value, data) {
	  return this.http.post(host.host + `/pathology/outpatient/${name}/${value}`,data, {
	    headers: this.headers,
	  });
	}
  // 删除故障现象
	deleteIncidentCategory(data) {
	  return this.http.post(host.host + `/incident/deleteIncidentCategory`, data, {
	    headers: this.headers,
	  });
	}
	// 综合统计
	getReportData(data) {
	  return this.http.post(host.host + `/itsm/report/index`, data, {
	    headers: this.headers,
	  });
	}
	// 获取deepSeek数据
	getDeepSeekData(data){
		return this.http.post(host.host + `/user/data/ds/chat`, data, {
		  headers: this.headers,
		});
	}
	// 导出deepSeek数据
	exportDeepSeek(data){
		return this.http.post(host.host + `/user/data/ds/exportChat`, data, {
		  headers: this.headers,
			responseType: "arraybuffer",
		});
	}
	// 恢复删除的用户
	recoveryUser(data){
		return this.http.post(host.host + `/user/data/recoveryUser`, data, {
		  headers: this.headers,
		});
	}
	// 闭环数据生成-生成数据
	generateData(data){
		return this.http.post(host.host + `/api/patchData/execute`, data, {
		  headers: this.headers,
		});
	}

	// 闭环数据生成-查询数据
	queryCount(data){
		return this.http.post(host.host + `/api/patchData/queryCount`, data, {
		  headers: this.headers,
		});
	}

  // 根据当前日期查询陪检批量建单设置中的默认时间
	getPatientInspectTime(data = {}){
		return this.http.post(host.host + `/nurse/patientInspect/getPatientInspectTime`, data, {
		  headers: this.headers,
		});
	}

  // 根据当前日期查询陪检批量建单设置中的默认时间
	bindPatientInspect(data = {}){
		return this.http.post(host.host + `/nurse/patientInspect/bindPatientInspect`, data, {
		  headers: this.headers,
		});
	}

  // 根据当患者查检查
	getPatientInspectList(data = {}){
		return this.http.post(host.host + `/nurse/patientInspect/getPatientInspectList`, data, {
		  headers: this.headers,
		});
	}

  // 批量-检查项目转检验项目
	addPatientInspectList(data = {}){
		return this.http.post(host.host + `/nurse/patientInspect/addPatientInspectList`, data, {
		  headers: this.headers,
		});
	}

  // 护士端-批量陪检图标下两个数字
	getPatientInspectCount(data = {}){
		return this.http.post(host.host + `/nurse/patientInspect/getPatientInspectCount`, data, {
		  headers: this.headers,
		});
	}

  // 标本打包-获取患者、试管类型列表、标本总数
	querySaveSpePackage(data = {}){
		return this.http.post(host.host + `/nurse/specimen/querySaveSpePackage`, data, {
		  headers: this.headers,
		});
	}

  // 标本打包-新增标本
	addPackageSpe(data = {}){
		return this.http.post(host.host + `/nurse/specimen/addPackageSpe`, data, {
		  headers: this.headers,
		});
	}

  // 标本打包-移除标本
	removePackageSpe(data = {}){
		return this.http.post(host.host + `/nurse/specimen/removePackageSpe`, data, {
		  headers: this.headers,
		});
	}

  // 标本打包-重置
	resetPackageSpe(data = {}){
		return this.http.post(host.host + `/nurse/specimen/resetPackageSpe`, data, {
		  headers: this.headers,
		});
	}

  // 标本打包-建单
	createOrTakeOrderSpecimen(data = {}){
		return this.http.post(host.host + `/transflow/createOrTakeOrder`, data, {
		  headers: this.headers,
		});
	}

  // 标本打包-打印
	makeQrCode(data = {}, code){
		return this.http.post(host.host + `/workerOrder/makeQrCode/specimenPackage/${code}`, data, {
		  headers: this.headers,
		});
	}

  // 护士端-标本打包图标下两个数字
	getSpePackageCount(data = {}){
		return this.http.post(host.host + `/nurse/specimen/getSpePackageCount`, data, {
		  headers: this.headers,
		});
	}

  // 标本打包-标本包里的标本的所有终点科室列表
	getSpePackageEndDeptList(data = {}){
		return this.http.post(host.host + `/nurse/specimen/getSpePackageEndDeptList`, data, {
		  headers: this.headers,
		});
	}

	// 文档管理上传
	documentImport(folderId, personal): string {
	  return `${host.host}/document/importFile/${folderId}/${personal}`;
	}

	// 文档管理更新
	documentUpdateFile(fileId): string {
	  return `${host.host}/document/updateFile/${fileId}`;
	}

	// 文档管理导出
	documentExport(fileToken): any {
	  return this.http.post(host.host + `/document/downloadFile/${fileToken}`,{}, {
	    headers: this.exportHeader,
	    responseType: "arraybuffer",
	  });
	}

  // 患者闭环-标记回科
	setPatientInspectBackDept(data = {}){
		return this.http.post(host.host + `/nurse/patientInspect/setPatientInspectBackDept`, data, {
		  headers: this.headers,
		});
	}

  // 患者-清空标记
	clearPatientMark(data = {}){
		return this.http.post(host.host + `/nurse/inspect/clearPatientMark`, data, {
		  headers: this.headers,
		});
	}


	// 调度台删除填写原因
	delWorkOrderWithReason(id, data){
		return this.http.post(host.host + `/workerOrder/delWorkOrderWithReason/${id}`, data, {
		  headers: this.headers,
		});
	}

	// 常用耗材缓存刷新
	resetCache(model){
		return this.http.post(host.host + `/incident/refresh/cache/${model}`, {}, {
		  headers: this.headers,
		});
	}

	// 故障工单-告警信息-建单
	addAlarmIncident(data){
		return this.http.post(host.host + `/flow/incident/task/createAlarmIncident`, data, {
		  headers: this.headers,
		});
	}

	// 获取登录验证码
	getLoginCode(data){
		return this.http.get(host.host + "/auth/captcha", {});
	}

	// 根据包号查看标本
	getInfoPack(packageId, data){
		return this.http.post(host.host + `/nurse/specimen/getInfo/${packageId}`, data);
	}
	
	// 业务信息自动生成
	autoMake(model, count, data){
		return this.http.post(host.host + `/testData/make/${model}/${count}`, data);
	}
	
	// 调度台一键派单
	oneClickAssignOrders(data){
		return this.http.post(host.host + `/ser/oneClickAssignOrders`, data);
	}
}
