Commit 4717b9a9e5ebd1fb44496333f9fac4d253d1d55c

Authored by zhangchao
1 parent 76fc7f2ca5
Exists in luanping

#fix:威县新增his工作站一键跳转相关功能

Showing 1 changed file with 1187 additions and 0 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWxController.java View file @ 4717b9a
Diff suppressed. Click to show
  1 +package com.lyms.platform.operate.web.controller;
  2 +
  3 +import com.lyms.platform.biz.service.*;
  4 +import com.lyms.platform.common.base.BaseController;
  5 +import com.lyms.platform.common.constants.ErrorCodeConstants;
  6 +import com.lyms.platform.common.dao.operator.MongoQuery;
  7 +import com.lyms.platform.common.result.BaseObjectResponse;
  8 +import com.lyms.platform.common.result.BaseResponse;
  9 +import com.lyms.platform.common.result.CommonResult;
  10 +import com.lyms.platform.common.utils.*;
  11 +import com.lyms.platform.operate.web.facade.*;
  12 +import com.lyms.platform.operate.web.request.AntExAddRequest;
  13 +import com.lyms.platform.operate.web.request.AntExQueryRequest;
  14 +import com.lyms.platform.operate.web.request.AntenatalExaminationQueryRequest;
  15 +import com.lyms.platform.operate.web.request.PatientQueryRequest;
  16 +import com.lyms.platform.operate.web.service.PatientWeightService;
  17 +import com.lyms.platform.operate.web.utils.CollectionUtils;
  18 +import com.lyms.platform.operate.web.utils.FunvCommonUtil;
  19 +import com.lyms.platform.permission.model.PatientService;
  20 +import com.lyms.platform.permission.model.PatientServiceQuery;
  21 +import com.lyms.platform.permission.service.CouponService;
  22 +import com.lyms.platform.permission.service.PatientServiceService;
  23 +import com.lyms.platform.pojo.*;
  24 +import com.lyms.platform.query.AntExChuQuery;
  25 +import com.lyms.platform.query.LisCrisisItemQuery;
  26 +import com.lyms.platform.query.PatientsQuery;
  27 +import org.springframework.beans.factory.annotation.Autowired;
  28 +import org.springframework.data.domain.Sort;
  29 +import org.springframework.stereotype.Controller;
  30 +import org.springframework.web.bind.annotation.*;
  31 +
  32 +import javax.servlet.http.HttpServletResponse;
  33 +import javax.validation.Valid;
  34 +import java.io.IOException;
  35 +import java.io.OutputStream;
  36 +import java.util.*;
  37 +
  38 +/**
  39 + * 邢台威县
  40 + */
  41 +@Controller
  42 +@RequestMapping
  43 +public class PatientWxController extends BaseController {
  44 + @Autowired
  45 + private PatientsService patientsService;
  46 + @Autowired
  47 + private PatientWeightService patientWeightService1;
  48 + @Autowired
  49 + private PatientWeightService2 patientWeightService;
  50 + @Autowired
  51 + private BloodPressureService bloodPressureService;
  52 + @Autowired
  53 + private AntenatalExaminationService antExService;
  54 + @Autowired
  55 + private BasicConfigService basicConfigService;
  56 + @Autowired
  57 + private AntenatalExaminationFacade antenatalExaminationFacade;
  58 + @Autowired
  59 + private ViewFacade viewFacade;
  60 + @Autowired
  61 + private StopPregnancyFacade stopPregnancyFacade;
  62 + @Autowired
  63 + private LisCrisisItemService lisCrisisItemService;
  64 + @Autowired
  65 + private PatientFacade patientFacade;
  66 + @Autowired
  67 + private CouponService couponService;
  68 + /* @Autowired
  69 + private AppointmentService appointmentService;*/
  70 + @Autowired
  71 + private PatientServiceService patientServiceService;
  72 + public static final String MEMBER_BABY_URL= PropertiesUtils.getPropertyValue("member_baby_url");
  73 +
  74 + final static Integer userId=2100006857;//默认为客服ID
  75 + final static String hospitalId="2100002421";//大同医院ID
  76 + final static String Authorization="1d$l*Y8lslp4dJLTsbm7LkM90";
  77 +
  78 +
  79 + /**
  80 + * 大同his获取孕妇小程序预建档信息——末次月经、血压、体重、既往史、个人史、家族史、传染病史、手术史数据
  81 + * @param idCard
  82 + * @param name
  83 + * @param phone
  84 + * @return
  85 + */
  86 + /*@RequestMapping(method = RequestMethod.GET, value = "/getDTPatient/Bookbuilding")
  87 + @ResponseBody
  88 + public BaseResponse getPatients(@RequestHeader("Authorization")String authorization, String idCard, String name, String phone){
  89 + BaseResponse baseResponse=new BaseResponse();
  90 +
  91 + if (!authorization.contains(Authorization)){
  92 + return baseResponse.setErrormsg("权限异常").setErrorcode(-1);
  93 + }
  94 +
  95 + PatientsQuery patientsQuery =new PatientsQuery();
  96 + patientsQuery.setYn(1);
  97 + patientsQuery.setHospitalId(hospitalId);
  98 + if (StringUtils.isNotEmpty(idCard)){
  99 + patientsQuery.setCardNo(idCard);
  100 + }else {
  101 + if (StringUtils.isNotEmpty(name)&&StringUtils.isNotEmpty(phone)){
  102 + patientsQuery.setName(name);
  103 + patientsQuery.setPhone(phone);
  104 + }else {
  105 + return baseResponse.setErrormsg("参数异常").setErrorcode(-1);
  106 + }
  107 + }
  108 + List<Patients> patientsList= patientsService.queryPatient(patientsQuery);
  109 + Map<String,Object> params=new HashMap<>();
  110 + if (CollectionUtils.isNotEmpty(patientsList)){
  111 + //处理预建档信息 末次月经、血压、体重、既往史、个人史、家族史、传染病史、手术史数据
  112 + Patients patients= patientsList.get(0);
  113 + String id=patients.getId();
  114 + params.put("lastMenses",patients.getLastMenses());
  115 + PatientWeightQuery patientWeightQuery=new PatientWeightQuery();
  116 + patientWeightQuery.setYn(1);
  117 + patientWeightQuery.setParentId(id);
  118 + MongoQuery mongoQuery=patientWeightQuery.convertToQuery().addOrder(Sort.Direction.DESC, "id");
  119 + List<PatientWeight> patientWeightList= patientWeightService.queryPatientWeight(mongoQuery.convertToMongoQuery());
  120 + if (CollectionUtils.isNotEmpty(patientWeightList)){
  121 + //体重
  122 + params.put("yqweight",patientWeightList.get(0).getNowWeight());
  123 + }
  124 + BloodPressureQuery bloodPressureQuery=new BloodPressureQuery();
  125 + bloodPressureQuery.setParentId(id);
  126 + bloodPressureQuery.setYn(1);
  127 + List<BloodPressure> list= bloodPressureService.getList(bloodPressureQuery);
  128 + if (CollectionUtils.isNotEmpty(list)){
  129 + BloodPressure bloodPressure= list.get(0);
  130 + //血压
  131 + params.put("bp", bloodPressure.getSsy() + "/" + bloodPressure.getSzy() + "mmHg");
  132 + }
  133 + AntExChuQuery antExChuQuery=new AntExChuQuery();
  134 + antExChuQuery.setYn(1);
  135 + antExChuQuery.setParentId(id);
  136 + List<AntExChuModel> antExChuModelList= antExService.queryAntExChu(antExChuQuery);
  137 + if (CollectionUtils.isNotEmpty(antExChuModelList)){
  138 + AntExChuModel data= antExChuModelList.get(0);
  139 + //既往史
  140 + String pastHistory = "";
  141 + if (org.apache.commons.lang.StringUtils.isNotEmpty(data.getPastHistory())) {
  142 + Map map1 = JsonUtil.jkstr2Obj(data.getPastHistory(), Map.class);
  143 + pastHistory = FunvCommonUtil.replace(map1, new StringBuilder(), basicConfigService);
  144 + }
  145 + params.put("pastHistory", pastHistory);
  146 + //家族史
  147 + String familyHistory = "";
  148 + if (org.apache.commons.lang.StringUtils.isNotEmpty(data.getFamilyHistory())) {
  149 + Map map1 = JsonUtil.jkstr2Obj(data.getFamilyHistory(), Map.class);
  150 + familyHistory = FunvCommonUtil.replace(map1, new StringBuilder(), basicConfigService);
  151 + }
  152 + params.put("familyHistory", familyHistory);
  153 + //个人史
  154 + String personalHistory = "";
  155 + if (org.apache.commons.lang.StringUtils.isNotEmpty(data.getPersonalHistory())) {
  156 + Map map1 = JsonUtil.jkstr2Obj(data.getPersonalHistory(), Map.class);
  157 + personalHistory = FunvCommonUtil.replace(map1, new StringBuilder(), basicConfigService);
  158 + }
  159 + params.put("personalHistory", personalHistory);
  160 + //妇科手术史
  161 + String fksxHistory = "";
  162 + if (org.apache.commons.lang.StringUtils.isNotEmpty(data.getFksxHistory())) {
  163 + Map map1 = JsonUtil.jkstr2Obj(data.getFksxHistory(), Map.class);
  164 + fksxHistory = FunvCommonUtil.replace(map1, new StringBuilder(), basicConfigService);
  165 + }
  166 + params.put("fksxHistory", fksxHistory);
  167 + //传染病史
  168 + String infectDiseases="";
  169 + if (org.apache.commons.lang.StringUtils.isNotEmpty(data.getInfectDiseases())) {
  170 + Map map1 = JsonUtil.jkstr2Obj(data.getInfectDiseases(), Map.class);
  171 + infectDiseases=FunvCommonUtil.reslove(map1, new StringBuilder());
  172 + }
  173 + params.put("infectDiseases", infectDiseases);
  174 +
  175 + }
  176 + }else {
  177 + return new BaseResponse().setErrormsg("当前用户未有建档信息").setErrorcode(41001);
  178 + }
  179 + baseResponse.setObject(params);
  180 + return baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功");
  181 + }*/
  182 +
  183 + /**
  184 + * 建档基础信息大同
  185 + * @param idCard
  186 + * @param name
  187 + * @param phone
  188 + * @return
  189 + */
  190 + @RequestMapping(method = RequestMethod.GET, value = "/wx/antexmanage")
  191 + @ResponseBody
  192 + public BaseResponse queryAntenatalExamination(@RequestHeader("Authorization")String authorization, String idCard, String name, String phone, String vcCardNo){
  193 + if (!authorization.contains(Authorization)){
  194 + return new BaseResponse().setErrormsg("权限异常").setErrorcode(-1);
  195 + }
  196 + String cardNo=idCard;
  197 + if (!StringUtils.isNotEmpty(idCard)){
  198 + if (StringUtils.isNotEmpty(name)&&StringUtils.isNotEmpty(phone)){
  199 + PatientsQuery patientsQuery =new PatientsQuery();
  200 + patientsQuery.setYn(1);
  201 + patientsQuery.setHospitalId(hospitalId);
  202 + patientsQuery.setName(name);
  203 + patientsQuery.setPhone(phone);
  204 + List<Patients> patientsList= patientsService.queryPatient(patientsQuery);
  205 + if (CollectionUtils.isNotEmpty(patientsList)){
  206 + cardNo=patientsList.get(0).getCardNo();
  207 + }else {
  208 + return new BaseResponse().setErrormsg("当前用户未有建档信息").setErrorcode(41001);
  209 + }
  210 + }
  211 +
  212 + if (StringUtils.isEmpty(cardNo)&&StringUtils.isEmpty(vcCardNo)){
  213 + return new BaseResponse().setErrormsg("参数异常").setErrorcode(-1);
  214 + }
  215 +
  216 + }
  217 + AntenatalExaminationQueryRequest queryRequest=new AntenatalExaminationQueryRequest();
  218 + queryRequest.setCardNo(cardNo);
  219 + queryRequest.setVcCardNo(vcCardNo);
  220 + return antenatalExaminationFacade.queryAntenatalExamination(queryRequest,userId);
  221 + }
  222 +
  223 + /**
  224 + * 高危威县
  225 + * @param patientId
  226 + * @return
  227 + */
  228 + @RequestMapping(method = RequestMethod.GET, value = "/wx/getLastRisk")
  229 + @ResponseBody
  230 + public BaseResponse getLastRisk(@RequestHeader("Authorization")String authorization, String patientId) {
  231 + if (!authorization.contains(Authorization)){
  232 + return new BaseResponse().setErrormsg("权限异常").setErrorcode(-1);
  233 + }
  234 + return antenatalExaminationFacade.getLastRisk(patientId, null);
  235 + }
  236 +
  237 + /**
  238 + * 检查报表
  239 + *
  240 + * @param antex
  241 + * @return
  242 + */
  243 + @RequestMapping(value = "/wx/checkReport", method = RequestMethod.GET)
  244 + @ResponseBody
  245 + public BaseResponse checkReport(@RequestHeader("Authorization")String authorization, @RequestParam(required = false) List<String> antex, @RequestParam(required = false) String antexc) {
  246 + if (!authorization.contains(Authorization)){
  247 + return new BaseResponse().setErrormsg("权限异常").setErrorcode(-1);
  248 + }
  249 + return viewFacade.checkReport(antex, antexc, userId);
  250 + }
  251 +
  252 + /**
  253 + * 查询复诊接口
  254 + *
  255 + * @param id
  256 + * @return
  257 + */
  258 + @RequestMapping(value = "/wx/findAntenatalExaminationData", method = RequestMethod.GET)
  259 + @ResponseBody
  260 + public BaseObjectResponse findAntenatalExaminationData(@RequestHeader("Authorization")String authorization, @RequestParam("id") String id) {
  261 + if (!authorization.contains(Authorization)){
  262 + return new BaseObjectResponse().setErrormsg("权限异常").setErrorcode(-1);
  263 + }
  264 + return viewFacade.findAntenatalExamination(id);
  265 + }
  266 +
  267 +
  268 + /**
  269 + * 返回该医院可选择的录入人
  270 + * 默认为客服号
  271 + * @return
  272 + */
  273 + @RequestMapping(method = RequestMethod.GET, value = "/wx/queryInPerson")
  274 + @ResponseBody
  275 + public BaseResponse queryInPerson(@RequestHeader("Authorization")String authorization) {
  276 + if (!authorization.contains(Authorization)){
  277 + return new BaseResponse().setErrormsg("权限异常").setErrorcode(-1);
  278 + }
  279 + return stopPregnancyFacade.queryInPerson(userId);
  280 + }
  281 +
  282 + /**
  283 + * 返回该医院可选择的录入人
  284 + * 默认为客服号
  285 + * @return
  286 + */
  287 + @RequestMapping(method = RequestMethod.GET, value = "/wx/queryInPerson2")
  288 + @ResponseBody
  289 + public BaseResponse queryInPerson2(@RequestHeader("Authorization")String authorization) {
  290 + if (!authorization.contains(Authorization)){
  291 + return new BaseResponse().setErrormsg("权限异常").setErrorcode(-1);
  292 + }
  293 + return stopPregnancyFacade.queryInPerson2(userId);
  294 + }
  295 +
  296 + /**
  297 + * 危急列表
  298 + * @param response
  299 + * @param page
  300 + * @param limit
  301 + * @param cardNo
  302 + * @param phone
  303 +
  304 + */
  305 + @RequestMapping(value = "/dt/lisCrisisItems", method = RequestMethod.GET)
  306 + public void getEmergenceTreatments(HttpServletResponse response,
  307 + @RequestHeader("Authorization")String authorization,
  308 + @RequestParam("page") int page,
  309 + @RequestParam("limit") int limit,
  310 + @RequestParam(value = "cardNo", required = false) String cardNo,
  311 + @RequestParam(value = "phone", required = false) String phone,
  312 + @RequestParam(value = "name", required = false) String name)
  313 + {
  314 + if (!authorization.contains(Authorization)){
  315 + ResultUtils.buildParameterErrorResultAndWrite(response, "权限异常");
  316 + return ;
  317 + }
  318 + LisCrisisItemQuery query = new LisCrisisItemQuery();
  319 + query.setPage(page);
  320 + query.setLimit(limit);
  321 + query.setNeed("y");
  322 + Boolean b=false;
  323 + if (StringUtils.isNotEmpty(cardNo)){
  324 + query.setCardNo(cardNo);
  325 + b=true;
  326 + }
  327 + if (StringUtils.isNotEmpty(phone)&&StringUtils.isNotEmpty(name)){
  328 + query.setPhone(phone);
  329 + query.setName(name);
  330 + b=true;
  331 + }
  332 + if (!b){
  333 + ResultUtils.buildParameterErrorResultAndWrite(response, "参数异常");
  334 + return;
  335 + }
  336 + query.setHospitalId(hospitalId);
  337 +
  338 +
  339 + List<LisCrisisItem> lisCrisisItemList = lisCrisisItemService.query(query, Sort.Direction.DESC, "publishTime");
  340 + List<Map> list = new ArrayList<>();
  341 +
  342 + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(lisCrisisItemList)) {
  343 + for (LisCrisisItem data : lisCrisisItemList) {
  344 + Map<String, Object> map = new HashMap<>();
  345 + map.put("id", data.getId());
  346 + map.put("hospitalId", data.getHospitalId());
  347 + map.put("name", data.getName());
  348 + map.put("age", data.getAge());
  349 + map.put("itemCode", data.getItemCode());
  350 + map.put("itemName", data.getItemName());
  351 + map.put("classify", data.getClassify());
  352 + map.put("classifyName", data.getClassifyName());
  353 + map.put("flag", data.getFlag());
  354 + map.put("ref", data.getRef());
  355 + map.put("result", data.getResult());
  356 + map.put("unit", data.getUnit());
  357 + map.put("applyDoctorCode", data.getApplyDoctorCode());
  358 + map.put("applyDoctorName", data.getApplyDoctorName());
  359 + map.put("publishTime", DateUtil.getyyyy_MM_dd(data.getPublishTime()));
  360 + map.put("status", data.getStatus());
  361 + map.put("statusName", data.getStatusName());
  362 +
  363 + map.put("patientName", data.getPatientName());
  364 + map.put("cardNo", data.getCardNo());
  365 + map.put("phone", data.getPhone());
  366 + map.put("serviceType", data.getServiceType());
  367 + map.put("serviceStatus", data.getServiceStatus());
  368 + map.put("lastMenses", data.getLastMenses() == null ? 0 : data.getLastMenses().getTime());
  369 +
  370 + if (data.getWeek() >= 42) {
  371 + map.put("week", "已分娩");
  372 + } else {
  373 + map.put("week", data.getWeek() + "周");
  374 + }
  375 + map.put("pId", data.getPid());
  376 + map.put("pid", data.getPid());
  377 + map.put("patientId", data.getPatientId());
  378 +
  379 + list.add(map);
  380 + }
  381 + }
  382 + CommonResult result = new CommonResult();
  383 + result.setList(list);
  384 + result.setPageInfo(query.getPageInfo());
  385 +
  386 + ResultUtils.buildSuccessResultAndWrite(response, result);
  387 + }
  388 +
  389 + @RequestMapping(value = "/dt/findp2", method = RequestMethod.GET)
  390 + @ResponseBody
  391 + public BaseResponse getPatent2(@Valid PatientQueryRequest request,
  392 + @RequestHeader("Authorization")String authorization) {
  393 + if (!authorization.contains(Authorization)){
  394 + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常");
  395 + }
  396 + return patientFacade.findPatient2(request, userId);
  397 + }
  398 +
  399 + @RequestMapping(method = RequestMethod.GET, value = "/dt/getGongGaoCurve")
  400 + @ResponseBody
  401 + public BaseResponse getGongGaoLine(@RequestParam(required = true) String patientId, @RequestHeader("Authorization")String authorization) {
  402 + if (!authorization.contains(Authorization)){
  403 + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常");
  404 + }
  405 + return antenatalExaminationFacade.getGongGaoLine(patientId, userId);
  406 + }
  407 +
  408 + @RequestMapping(method = RequestMethod.GET, value = "/wx/antex")
  409 + @ResponseBody
  410 + public BaseResponse findOneAntById(@RequestHeader("Authorization")String authorization, @Valid AntExQueryRequest antExQueryRequest) {
  411 + if (!authorization.contains(Authorization)){
  412 + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常");
  413 + }
  414 + antExQueryRequest.setUserId(userId);
  415 + return antenatalExaminationFacade.findOneAntExById(antExQueryRequest);
  416 + }
  417 +
  418 + @RequestMapping(method = RequestMethod.POST, value = "/wx/antexmanage")
  419 + @ResponseBody
  420 + public BaseResponse addOneAntenatalExamination(@RequestHeader("Authorization")String authorization, @Valid @RequestBody AntExAddRequest antExAddRequest) {
  421 + if (!authorization.contains(Authorization)){
  422 + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常");
  423 + }
  424 + BaseResponse baseResponse = antenatalExaminationFacade.addOneAntEx(antExAddRequest, userId);
  425 + baseResponse.setObject(couponService.getPatientsInfoByCode(antExAddRequest.getCouponCode()));
  426 + return baseResponse;
  427 + }
  428 +
  429 + /**
  430 + * 获取体重列表;
  431 + * @param authorization
  432 + * @param id
  433 + * @return
  434 + */
  435 + @ResponseBody
  436 + @RequestMapping(value = "/dt/patient/weight/info/{id}", method = RequestMethod.GET)
  437 + public BaseResponse info(@RequestHeader("Authorization")String authorization, @PathVariable String id) {
  438 + if (!authorization.contains(Authorization)){
  439 + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常");
  440 + }
  441 + return patientWeightService1.info(id);
  442 + }
  443 +
  444 + /**
  445 + * 添加体重管理
  446 + * @param patientWeight
  447 + * @return
  448 + */
  449 + /* @ResponseBody
  450 + @RequestMapping(value = "/dt/patient/weight",method = RequestMethod.POST)
  451 + public BaseResponse addOrUpdate(@RequestHeader("Authorization")String authorization, PatientWeight patientWeight) {
  452 + if (!authorization.contains(Authorization)){
  453 + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常");
  454 + }
  455 + return patientWeightService1.addOrUpdate(userId, patientWeight);
  456 + }*/
  457 + /*@Autowired
  458 + private PregnancyReportFacade pregnancyReportFacade;*/
  459 +
  460 + /**
  461 + * 获取患者体重报告
  462 + * @return
  463 + */
  464 + /*@RequestMapping(method = RequestMethod.GET, value = "/dt/getPatientReport")
  465 + @ResponseBody
  466 + public BaseResponse getPatientReport(@RequestParam(required = false) String name,
  467 + @RequestParam(required = false) Integer week,
  468 + @RequestParam(required = false) Integer weightType,
  469 + @RequestHeader("Authorization")String authorization){
  470 + if (!authorization.contains(Authorization)){
  471 + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常");
  472 + }
  473 + PregnancyReportQuery pregnancyReportQuery=new PregnancyReportQuery();
  474 + pregnancyReportQuery.setWeek(week);
  475 + pregnancyReportQuery.setWeightType(weightType);
  476 + pregnancyReportQuery.setName(name);
  477 + return pregnancyReportFacade.getPatientReport(pregnancyReportQuery,userId);
  478 + }*/
  479 + /* @Autowired
  480 + private PregnancyReportMattersServiceFacade pregnancyReportMattersServiceFacade;
  481 + *//**
  482 + * 获取模版列表
  483 + * @return
  484 + *//*
  485 + @RequestMapping(method = RequestMethod.GET, value = "/dt/matters/getList")
  486 + @ResponseBody
  487 + public BaseResponse getMattersList(
  488 + @RequestHeader("Authorization")String authorization,
  489 + @RequestParam(required = false) Integer week,
  490 + @RequestParam(required = false) Integer riskType,
  491 + @RequestParam Integer type,
  492 + @RequestParam(required = false) String name,
  493 + @RequestParam("page") Integer page,
  494 + @RequestParam("limit") Integer limit
  495 + ){
  496 + if (!authorization.contains(Authorization)){
  497 + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常");
  498 + }
  499 + PregnancyReportMattersQuery postpartumReportQuery=new PregnancyReportMattersQuery();
  500 + postpartumReportQuery.setWeek(week);
  501 + postpartumReportQuery.setType(type);
  502 + postpartumReportQuery.setRiskType(riskType);
  503 + postpartumReportQuery.setPage(page);
  504 + postpartumReportQuery.setLimit(limit);
  505 + postpartumReportQuery.setName(name);
  506 + return pregnancyReportMattersServiceFacade.getList(postpartumReportQuery,userId);
  507 + }
  508 +
  509 + *//**
  510 + * 获取高危饮食原则模版详情
  511 + * @return
  512 + *//*
  513 + @RequestMapping(method = RequestMethod.GET, value = "/dt/matters/getRisk")
  514 + @ResponseBody
  515 + public BaseResponse getReportByRisk(@RequestHeader("Authorization")String authorization, @RequestParam Integer week, @RequestParam Integer type,
  516 + @RequestParam String riskFactorId){
  517 + if (!authorization.contains(Authorization)){
  518 + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常");
  519 + }
  520 + BaseResponse baseResponse= new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功");
  521 + PregnancyReportMattersQuery postpartumReportQuery=new PregnancyReportMattersQuery();
  522 + postpartumReportQuery.setWeek(week);
  523 + postpartumReportQuery.setType(type);
  524 + postpartumReportQuery.setRiskFactorId(StringUtils.covertToList(riskFactorId, String.class));
  525 + baseResponse.setObject(pregnancyReportMattersServiceFacade.getReportByRisk(postpartumReportQuery,userId));
  526 + return baseResponse;
  527 + }
  528 + *//**
  529 + * 获取模版详情
  530 + * @return
  531 + *//*
  532 + @RequestMapping(method = RequestMethod.GET, value = "/dt/matters/getInfo")
  533 + @ResponseBody
  534 + public BaseResponse getMattersList(@RequestHeader("Authorization")String authorization, String id){
  535 + if (!authorization.contains(Authorization)){
  536 + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常");
  537 + }
  538 + BaseResponse baseResponse= new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功");
  539 + baseResponse.setObject(pregnancyReportMattersServiceFacade.getPregnancyReport(id));
  540 + return baseResponse;
  541 + }*/
  542 +
  543 + /**
  544 + * 查询初诊接口
  545 + *
  546 + * @param id
  547 + * @return
  548 + */
  549 + @RequestMapping(value = "/wx/findAntExChuData", method = RequestMethod.GET)
  550 + @ResponseBody
  551 + public BaseObjectResponse findAntExChuData(@RequestParam("id") String id,
  552 + @RequestHeader("Authorization")String authorization) {
  553 + if (!authorization.contains(Authorization)){
  554 + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常");
  555 + }
  556 + BaseObjectResponse br = viewFacade.findAntExChu(id);
  557 + return br;
  558 + }
  559 +
  560 + /* @Autowired
  561 + private LisFacade lisFacade;
  562 +
  563 + @RequestMapping(method = RequestMethod.GET, value = "/dt/getLisAndRisData")
  564 + @ResponseBody
  565 + public BaseResponse getLisAndRisData(@RequestHeader("Authorization")String authorization,
  566 + @RequestParam(required = false) String vcCardNo,
  567 + @RequestParam(required = false) String sINCard,
  568 + @RequestParam("sortType") Integer sortType,
  569 + @RequestParam(required = false) String phone,
  570 + @RequestParam(required = false) String cardNo,
  571 + @RequestParam(required = false) String userName,
  572 + @RequestParam(defaultValue = "1") Integer perType//默认孕妇
  573 + ) {
  574 + if (!authorization.contains(Authorization)){
  575 + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常");
  576 + }
  577 + return lisFacade.getLisAndRisData(vcCardNo,sINCard, phone,cardNo, sortType,perType, userName,userId);
  578 + }
  579 +
  580 + *//**
  581 + * 增加产检高危手册(大同)
  582 + * @param antExHighRiskModel
  583 + * @return
  584 + *//*
  585 + @RequestMapping(method = RequestMethod.POST, value = "/dt/addAntexHighRisk")
  586 + @ResponseBody
  587 + public BaseResponse addAntexHighRisk(@RequestHeader("Authorization")String authorization, @RequestBody AntExHighRiskModel antExHighRiskModel){
  588 + if (!authorization.contains(Authorization)){
  589 + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常");
  590 + }
  591 + return antenatalExaminationFacade.addAntexHighRisk(antExHighRiskModel,userId);
  592 + }
  593 +
  594 + *//**
  595 + * 查询产检高危手册(大同)
  596 + * @param parentId
  597 + * @return
  598 + *//*
  599 + @RequestMapping(method = RequestMethod.GET, value = "/dt/queryAntexHighRisk")
  600 + @ResponseBody
  601 + public BaseResponse queryAntexHighRisk(@RequestHeader("Authorization")String authorization, @RequestParam String parentId){
  602 + if (!authorization.contains(Authorization)){
  603 + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常");
  604 + }
  605 + return antenatalExaminationFacade.queryAntexHighRisk(parentId,userId);
  606 + }
  607 +
  608 + @RequestMapping(method = RequestMethod.POST, value = "/dt/addPatientNipt")
  609 + @ResponseBody
  610 + public BaseResponse addPatientNipt(@RequestHeader("Authorization")String authorization, @RequestBody PatientNiptDTO patientNiptDTO){
  611 + if (!authorization.contains(Authorization)){
  612 + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常");
  613 + }
  614 + return antenatalExaminationFacade.addPatientNipt(patientNiptDTO,userId);
  615 + }*/
  616 + //大同需要特殊处理的护士名称
  617 + private static final String doctors="孙慧洁,曹琴,温燕芳,牛冬燕,王改然,杜文瑞,习亚美,卫娜,施春花,胡雪娇,田保来";
  618 +
  619 + /**
  620 + * 预约挂号列表查询
  621 + * @param authorization
  622 + * @param doctor
  623 + * @param startTime
  624 + * @param endTime
  625 + * @param name
  626 + * @return
  627 + */
  628 + /*@RequestMapping(method = RequestMethod.GET, value = "/dt/appointment")
  629 + @ResponseBody
  630 + public BaseResponse getAppointment(@RequestHeader("Authorization")String authorization,
  631 + @RequestParam String doctor,
  632 + @RequestParam String startTime,
  633 + @RequestParam String endTime,
  634 + @RequestParam(required = false) Integer isBuild,
  635 + @RequestParam(required = false) Integer expire,
  636 + @RequestParam(required = false) String name,
  637 + @RequestParam(required = false) String doctorName,
  638 + @RequestParam(required = false) Integer page,
  639 + @RequestParam(required = false) Integer limit
  640 +
  641 + ) {
  642 + if (!authorization.contains(Authorization)){
  643 + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常");
  644 + }
  645 + BaseResponse baseResponse=new BaseResponse();
  646 + startTime=startTime+" 00:00:00";
  647 + endTime=endTime+" 23:59:59";
  648 + String dept=null;
  649 + String need=null;
  650 + if (doctors.contains(doctor)){
  651 + doctor=doctorName;
  652 + dept="产科";
  653 + if (isBuild==null && expire==null){
  654 + need="true";
  655 + }
  656 + }
  657 + AppointmentQuery appointmentQuery=new AppointmentQuery();
  658 + appointmentQuery.setDoctor(doctor);
  659 + appointmentQuery.setStartTime(startTime);
  660 + appointmentQuery.setEndTime(endTime);
  661 + appointmentQuery.setDept(dept);
  662 + appointmentQuery.setName(name);
  663 + appointmentQuery.setNeed(need);
  664 + appointmentQuery.setLimit(limit);
  665 + appointmentQuery.setPage(page);
  666 + List<AppointmentModel> modelList= appointmentService.queryAppointment(appointmentQuery);
  667 + Date date=new Date();
  668 + if (CollectionUtils.isNotEmpty(modelList)){
  669 + Map params=new HashMap();
  670 + boolean b=true;
  671 + if (expire!=null || isBuild!=null){
  672 + b=false;
  673 + }
  674 + List<AppointmentModel> checkList=new ArrayList<>();
  675 + PatientsQuery patientsQuery =new PatientsQuery();
  676 + patientsQuery.setYn(1);
  677 + patientsQuery.setHospitalId(hospitalId);
  678 + for (int i = 0,j=modelList.size(); i < j; i++) {
  679 + AppointmentModel appointmentModel= modelList.get(i);
  680 + if (StringUtils.isNotEmpty(appointmentModel.getDoctor())){
  681 + String idCard=appointmentModel.getIdCard();
  682 + String phone=appointmentModel.getPhone();
  683 + String username=appointmentModel.getName();
  684 + if (StringUtils.isNotEmpty(idCard)){
  685 + patientsQuery.setName(null);
  686 + patientsQuery.setPhone(null);
  687 + patientsQuery.setCardNo(idCard);
  688 + }else {
  689 + if (StringUtils.isNotEmpty(username)&&StringUtils.isNotEmpty(phone)){
  690 + patientsQuery.setCardNo(null);
  691 + patientsQuery.setName(username);
  692 + patientsQuery.setPhone(phone);
  693 + }else {
  694 + appointmentModel.setIsBuild(0);
  695 + appointmentModel.setExpire(1);
  696 + appointmentQuery.setIdCard(idCard);
  697 + appointmentModel.setAppointmentNum(appointmentService.queryAppointmentCount(appointmentQuery));
  698 + }
  699 + }
  700 + if (appointmentModel.getIsBuild()==null){
  701 + List<Patients> patientsList= patientsService.queryPatient(patientsQuery);
  702 + if (CollectionUtils.isNotEmpty(patientsList)){
  703 + appointmentModel.setIsBuild(1);
  704 + Patients patients= patientsList.get(0);
  705 + appointmentModel.setBookbuildingDate(patients.getBookbuildingDate());
  706 + PatientServiceQuery patientQuery = new PatientServiceQuery();
  707 + patientQuery.setParentid(patients.getId());
  708 + patientQuery.setSerType(1);
  709 + List<PatientService> patientServices = patientServiceService.queryPatientService(patientQuery);
  710 + if (CollectionUtils.isNotEmpty(patientServices)){
  711 + Date serEndTime= patientServices.get(0).getSerEndTime();
  712 + Date serStartTime=patientServices.get(0).getUpdateDate();
  713 + appointmentModel.setSerEndTime(serEndTime);
  714 + appointmentModel.setSerStartTime(serStartTime);
  715 + if (serEndTime.compareTo(date)>0){
  716 + appointmentModel.setExpire(0);
  717 + }else {
  718 + appointmentModel.setExpire(1);
  719 + }
  720 + }else {
  721 + appointmentModel.setExpire(1);
  722 + }
  723 +
  724 + if (org.apache.commons.lang.StringUtils.isNotEmpty(patients.getRiskLevelId()) && !"[]".equals(patients.getRiskLevelId())) {
  725 + List level = new ArrayList();
  726 + try {
  727 + List<String> list = JsonUtil.patientRiskLevelIdToList(patients.getRiskLevelId());
  728 + for (String str : list) {
  729 + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(str);
  730 + if (null != basicConfig) {
  731 + Map map = new HashMap();
  732 + basicConfig.replenRisk(map);
  733 + if (!level.contains(map)){
  734 + level.add(map);
  735 + }
  736 + }
  737 + }
  738 + } catch (Exception e) {
  739 + ExceptionUtils.catchException(e, "patients.getRiskLevelId error.");
  740 + }
  741 + appointmentModel.setrlevel(level);
  742 + }
  743 + }else {
  744 + appointmentModel.setIsBuild(0);
  745 + appointmentModel.setExpire(1);
  746 + if (appointmentModel.getAppointmentNum()==null || appointmentModel.getAppointmentNum()==0){
  747 + appointmentQuery.setIdCard(idCard);
  748 + appointmentModel.setAppointmentNum(appointmentService.queryAppointmentCount(appointmentQuery));
  749 + }
  750 + }
  751 + }
  752 + if (isBuild!=null){
  753 + if (expire!=null){
  754 + if (appointmentModel.getIsBuild()==isBuild&&appointmentModel.getExpire()==expire){
  755 + checkList.add(appointmentModel);
  756 + }
  757 + }else {
  758 + if (appointmentModel.getIsBuild()==isBuild){
  759 + checkList.add(appointmentModel);
  760 + }
  761 + }
  762 + }else {
  763 + if (expire!=null){
  764 + if (appointmentModel.getExpire()==expire){
  765 + checkList.add(appointmentModel);
  766 + }
  767 + }
  768 + }
  769 + }
  770 +
  771 + }
  772 +
  773 + if (b){
  774 + params.put("data",modelList);
  775 + }else {
  776 + params.put("data",checkList);
  777 + }
  778 + if (StringUtils.isNotEmpty(need)){
  779 + params.put("pageInfo",appointmentQuery.getPageInfo());
  780 + }
  781 + baseResponse.setObject(params);
  782 + }
  783 + baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功");
  784 + return baseResponse;
  785 + }
  786 +
  787 + *//**
  788 + * 预约统计管理科室统计列表
  789 + * @param authorization
  790 + * @param doctor
  791 + * @param startTime
  792 + * @param endTime
  793 + * @return
  794 + *//*
  795 + @RequestMapping(method = RequestMethod.GET, value = "/dt/appointment/dept/statistics")
  796 + @ResponseBody
  797 + public BaseResponse appointmentDeptStatistics(@RequestHeader("Authorization")String authorization,
  798 + @RequestParam String doctor,
  799 + @RequestParam String startTime,
  800 + @RequestParam String endTime){
  801 + if (!authorization.contains(Authorization)){
  802 + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常");
  803 + }
  804 + BaseResponse baseResponse=new BaseResponse();
  805 + startTime=startTime+" 00:00:00";
  806 + endTime=endTime+" 23:59:59";
  807 + String dept=null;
  808 + //只有护士长和主任可以看统计(目前)
  809 + if (doctor.equals("田保来")||doctor.equals("孙慧洁")){
  810 + dept="产科";
  811 + }else {
  812 + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常");
  813 + }
  814 + AppointmentQuery appointmentQuery=new AppointmentQuery();
  815 + appointmentQuery.setStartTime(startTime);
  816 + appointmentQuery.setEndTime(endTime);
  817 + appointmentQuery.setDept(dept);
  818 + List<AppointmentModel> modelList= appointmentService.queryAppointment(appointmentQuery);
  819 + if (CollectionUtils.isNotEmpty(modelList)){
  820 + Map<String,AppointmentData> params=new HashMap();
  821 + PatientsQuery patientsQuery =new PatientsQuery();
  822 + patientsQuery.setYn(1);
  823 + patientsQuery.setHospitalId(hospitalId);
  824 + for (int i = 0,j=modelList.size(); i < j; i++) {
  825 + AppointmentModel appointmentModel= modelList.get(i);
  826 + String depts=appointmentModel.getDept();
  827 + if (StringUtils.isNotEmpty(depts)){
  828 + AppointmentData appointmentData= params.get(depts);
  829 + if (appointmentData==null){
  830 + appointmentData=new AppointmentData();
  831 + }
  832 + appointmentData.setDept(depts);
  833 + String idCard=appointmentModel.getIdCard();
  834 + String phone=appointmentModel.getPhone();
  835 + String username=appointmentModel.getName();
  836 + if (StringUtils.isNotEmpty(idCard)){
  837 + patientsQuery.setName(null);
  838 + patientsQuery.setPhone(null);
  839 + patientsQuery.setCardNo(idCard);
  840 + }else {
  841 + if (StringUtils.isNotEmpty(username)&&StringUtils.isNotEmpty(phone)){
  842 + patientsQuery.setCardNo(null);
  843 + patientsQuery.setName(username);
  844 + patientsQuery.setPhone(phone);
  845 + }else {
  846 + appointmentModel.setIsBuild(0);
  847 + //未建档
  848 + appointmentData.setUnBuildNum(appointmentData.getUnBuildNum()!=null?appointmentData.getUnBuildNum()+1:1);
  849 + }
  850 + }
  851 + if (appointmentModel.getIsBuild()==null){
  852 + List<Patients> patientsList= patientsService.queryPatient(patientsQuery);
  853 + if (CollectionUtils.isNotEmpty(patientsList)){
  854 + //已经建档
  855 + //新建档人数等于当天建档人数
  856 + appointmentData.setBuildNum(appointmentData.getBuildNum()!=null?appointmentData.getBuildNum()+1:1);
  857 + Patients patients= patientsList.get(0);
  858 + if (DateUtil.isBetween(patients.getCreated(),DateUtil.parseYMDHMS(startTime),DateUtil.parseYMDHMS(endTime))){
  859 + appointmentData.setNewBuildNum(appointmentData.getNewBuildNum()!=null?appointmentData.getNewBuildNum()+1:1);
  860 + }
  861 + }else {
  862 + //未建档
  863 + appointmentData.setUnBuildNum(appointmentData.getUnBuildNum()!=null?appointmentData.getUnBuildNum()+1:1);
  864 + }
  865 + }
  866 + appointmentData.setAppointmentNum(appointmentData.getAppointmentNum()!=null?appointmentData.getAppointmentNum()+1:1);
  867 + params.put(depts,appointmentData);
  868 + }
  869 + }
  870 + // 使用TreeMap进行排序
  871 + Map<String, AppointmentData> sortedMap = new TreeMap<>(new ChineseComparator());
  872 + sortedMap.putAll(params);
  873 + baseResponse.setObject(sortedMap);
  874 + }
  875 + baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功");
  876 + return baseResponse;
  877 + }
  878 + // 自定义Comparator,用于按照定义好的顺序排序
  879 + static class ChineseComparator implements Comparator<String> {
  880 + @Override
  881 + public int compare(String s1, String s2) {
  882 + try {
  883 + return getPinyin(s1).compareTo(getPinyin(s2));
  884 + }catch (Exception e){
  885 + System.out.println(s1+" "+s2);
  886 + }
  887 + return 0;
  888 + }
  889 +
  890 + }
  891 + private static Integer getPinyin(String s) {
  892 + Map<String, Integer> map = new HashMap<>();
  893 + map.put("产后康复门诊", 10);
  894 + map.put("产科七病区", 7);
  895 + map.put("产科三病区", 3);
  896 + map.put("产科二病区", 2);
  897 + map.put("产科五病区", 5);
  898 + map.put("产科六病区", 6);
  899 + map.put("产科门诊", 1);
  900 + return map.get(s);
  901 + }
  902 +
  903 + *//**
  904 + * 预约统计管理列表
  905 + * @param authorization
  906 + * @param doctor
  907 + * @param startTime
  908 + * @param endTime
  909 + * @return
  910 + *//*
  911 + @RequestMapping(method = RequestMethod.GET, value = "/dt/appointment/statistics")
  912 + @ResponseBody
  913 + public BaseResponse appointmentStatistics(@RequestHeader("Authorization")String authorization,
  914 + @RequestParam String doctor,
  915 + @RequestParam String startTime,
  916 + @RequestParam String endTime,
  917 + @RequestParam(required = false) String deptName
  918 + ){
  919 + if (!authorization.contains(Authorization)){
  920 + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常");
  921 + }
  922 + BaseResponse baseResponse=new BaseResponse();
  923 + startTime=startTime+" 00:00:00";
  924 + endTime=endTime+" 23:59:59";
  925 + String dept=null;
  926 + //只有护士长和主任可以看统计(目前)
  927 + if (doctor.equals("田保来")||doctor.equals("孙慧洁")){
  928 + if (StringUtils.isEmpty(deptName)){
  929 + dept="产科";
  930 + }
  931 + }else {
  932 + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常");
  933 + }
  934 + AppointmentQuery appointmentQuery=new AppointmentQuery();
  935 + appointmentQuery.setStartTime(startTime);
  936 + appointmentQuery.setEndTime(endTime);
  937 + appointmentQuery.setDept(dept);
  938 + appointmentQuery.setDeptName(deptName);
  939 + List<AppointmentModel> modelList= appointmentService.queryAppointment(appointmentQuery);
  940 + if (CollectionUtils.isNotEmpty(modelList)){
  941 + Map<String,AppointmentData> params=new HashMap();
  942 + PatientsQuery patientsQuery =new PatientsQuery();
  943 + patientsQuery.setYn(1);
  944 + patientsQuery.setHospitalId(hospitalId);
  945 + for (int i = 0,j=modelList.size(); i < j; i++) {
  946 + AppointmentModel appointmentModel= modelList.get(i);
  947 + String doctorName=StringUtils.isNotEmpty(appointmentModel.getDoctor())?appointmentModel.getDoctor():"-";
  948 + AppointmentData appointmentData= params.get(doctorName);
  949 + if (appointmentData==null){
  950 + appointmentData=new AppointmentData();
  951 + }
  952 + appointmentData.setDoctor(doctorName);
  953 + if (StringUtils.isEmpty(appointmentData.getDept())){
  954 + appointmentData.setDept(appointmentModel.getDept());
  955 + }
  956 + String idCard=appointmentModel.getIdCard();
  957 + String phone=appointmentModel.getPhone();
  958 + String username=appointmentModel.getName();
  959 + if (StringUtils.isNotEmpty(idCard)){
  960 + patientsQuery.setName(null);
  961 + patientsQuery.setPhone(null);
  962 + patientsQuery.setCardNo(idCard);
  963 + }else {
  964 + if (StringUtils.isNotEmpty(username)&&StringUtils.isNotEmpty(phone)){
  965 + patientsQuery.setCardNo(null);
  966 + patientsQuery.setName(username);
  967 + patientsQuery.setPhone(phone);
  968 + }else {
  969 + appointmentModel.setIsBuild(0);
  970 + //未建档
  971 + appointmentData.setUnBuildNum(appointmentData.getUnBuildNum()!=null?appointmentData.getUnBuildNum()+1:1);
  972 + }
  973 + }
  974 + if (appointmentModel.getIsBuild()==null){
  975 + List<Patients> patientsList= patientsService.queryPatient(patientsQuery);
  976 + if (CollectionUtils.isNotEmpty(patientsList)){
  977 + //已经建档
  978 + //新建档人数等于当天建档人数
  979 + Patients patients= patientsList.get(0);
  980 + if (DateUtil.isBetween(patients.getCreated(),DateUtil.parseYMDHMS(startTime),DateUtil.parseYMDHMS(endTime))){
  981 + appointmentData.setNewBuildNum(appointmentData.getNewBuildNum()!=null?appointmentData.getNewBuildNum()+1:1);
  982 + }
  983 + appointmentData.setBuildNum(appointmentData.getBuildNum()!=null?appointmentData.getBuildNum()+1:1);
  984 + }else {
  985 + //未建档
  986 + appointmentData.setUnBuildNum(appointmentData.getUnBuildNum()!=null?appointmentData.getUnBuildNum()+1:1);
  987 + }
  988 + }
  989 + appointmentData.setAppointmentNum(appointmentData.getAppointmentNum()!=null?appointmentData.getAppointmentNum()+1:1);
  990 + params.put(doctorName,appointmentData);
  991 + }
  992 + baseResponse.setObject(params);
  993 + }
  994 + baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功");
  995 + return baseResponse;
  996 + }
  997 +
  998 + *//**
  999 + * 统计数据导出
  1000 + *//*
  1001 + @RequestMapping(method = RequestMethod.POST, value = "/dt/appointment/statistics/export")
  1002 + @ResponseBody
  1003 + public void statisticsExport(@RequestHeader("Authorization")String authorization,
  1004 + @RequestBody AppointmentExport appointmentExport,
  1005 + HttpServletResponse response){
  1006 + if (authorization.contains(Authorization)){
  1007 + String doctor= appointmentExport.getDoctor();
  1008 + String dept=null;
  1009 + if (doctor.equals("田保来")||doctor.equals("孙慧洁")){
  1010 + dept="产科";
  1011 + }else {
  1012 + return;
  1013 + }
  1014 + try {
  1015 + Map <String, String> cnames = new LinkedHashMap <>();
  1016 + cnames.put("dept", "科室");
  1017 + cnames.put("appointmentSumNum", "科室预约就诊总人数");
  1018 + cnames.put("buildSumNum", "科室建立电子档案总人数");
  1019 + cnames.put("newBuildSumNum", "科室新建档总人数");
  1020 + cnames.put("unBuildSumNum", "科室未档总人数");
  1021 + cnames.put("buildSumRate", "科室已建档总比率");//已建档/总
  1022 + cnames.put("newBuildSumRate", "科室新建档总比率");//新建/(总-已建档+新建档)
  1023 + cnames.put("doctor", "医生");
  1024 + cnames.put("appointmentNum", "预约就诊人数");
  1025 + cnames.put("buildNum", "建立电子档案人数");
  1026 + cnames.put("newBuildNum", "新建档人数");
  1027 + cnames.put("unBuildNum", "未档总人数");
  1028 + cnames.put("buildRate", "已建档比率");
  1029 + cnames.put("newBuildRate", "新建档比率");
  1030 + response.setContentType("application/octet-stream");
  1031 + response.setHeader("Content-Disposition", "attachment;fileName=" + "科室建档统计.xls");
  1032 + OutputStream out = response.getOutputStream();
  1033 + Map<String,Map<String,Object>> params= appointmentExport.getParams();
  1034 + AppointmentQuery appointmentQuery=new AppointmentQuery();
  1035 + String startTime=appointmentExport.getStartTime()+" 00:00:00";
  1036 + String endTime=appointmentExport.getEndTime()+" 23:59:59";
  1037 + appointmentQuery.setStartTime(startTime);
  1038 + appointmentQuery.setEndTime(endTime);
  1039 + appointmentQuery.setDept(dept);
  1040 + List<AppointmentModel> modelList= appointmentService.queryAppointment(appointmentQuery);
  1041 + if (CollectionUtils.isNotEmpty(modelList)&&!params.isEmpty()){
  1042 + Map<String,List<Map<String,Object>>> data=new HashMap();
  1043 + Map<String,Map<String,Object>> params1=new HashMap();
  1044 + PatientsQuery patientsQuery =new PatientsQuery();
  1045 + patientsQuery.setYn(1);
  1046 + patientsQuery.setHospitalId(hospitalId);
  1047 + for (int i = 0,j=modelList.size(); i < j; i++) {
  1048 + AppointmentModel appointmentModel= modelList.get(i);
  1049 + String doctorName=StringUtils.isNotEmpty(appointmentModel.getDoctor())?appointmentModel.getDoctor():"-";
  1050 + String depts=appointmentModel.getDept();
  1051 + Map<String,Object> appointmentData= params1.get(doctorName+","+depts);
  1052 + if (appointmentData==null){
  1053 + appointmentData=new HashMap<>();
  1054 + }
  1055 + appointmentData.put("doctor",doctorName);
  1056 + appointmentData.put("dept",depts);
  1057 + String idCard=appointmentModel.getIdCard();
  1058 + String phone=appointmentModel.getPhone();
  1059 + String username=appointmentModel.getName();
  1060 + if (StringUtils.isNotEmpty(idCard)){
  1061 + patientsQuery.setName(null);
  1062 + patientsQuery.setPhone(null);
  1063 + patientsQuery.setCardNo(idCard);
  1064 + }else {
  1065 + if (StringUtils.isNotEmpty(username)&&StringUtils.isNotEmpty(phone)){
  1066 + patientsQuery.setCardNo(null);
  1067 + patientsQuery.setName(username);
  1068 + patientsQuery.setPhone(phone);
  1069 + }else {
  1070 + appointmentModel.setIsBuild(0);
  1071 + //未建档
  1072 + appointmentData.put("unBuildNum",appointmentData.get("unBuildNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("unBuildNum")))+1:1);
  1073 + }
  1074 + }
  1075 + if (appointmentModel.getIsBuild()==null){
  1076 + List<Patients> patientsList= patientsService.queryPatient(patientsQuery);
  1077 + if (CollectionUtils.isNotEmpty(patientsList)){
  1078 + //已经建档
  1079 + //新建档人数等于当天建档人数
  1080 + appointmentData.put("buildNum",appointmentData.get("buildNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("buildNum")))+1:1);
  1081 + Patients patients= patientsList.get(0);
  1082 + if (DateUtil.isBetween(patients.getCreated(),DateUtil.parseYMDHMS(startTime),DateUtil.parseYMDHMS(endTime))){
  1083 + appointmentData.put("newBuildNum",appointmentData.get("newBuildNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("newBuildNum")))+1:1);
  1084 + }
  1085 + }else {
  1086 + //未建档
  1087 + appointmentData.put("unBuildNum",appointmentData.get("unBuildNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("unBuildNum")))+1:1);
  1088 + }
  1089 + }
  1090 + appointmentData.put("appointmentNum",appointmentData.get("appointmentNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("appointmentNum")))+1:1);
  1091 + params1.put(doctorName+","+depts,appointmentData);
  1092 +
  1093 + }
  1094 + for (Map.Entry<String,Map<String,Object>> entry: params1.entrySet()) {
  1095 + Map<String,Object> value= entry.getValue();
  1096 + // System.out.println(value);
  1097 + String deptName= String.valueOf(value.get("dept"));
  1098 + if (StringUtils.isNotEmpty(deptName)){
  1099 + List<Map<String,Object>> data1 =data.get(deptName);
  1100 + if (CollectionUtils.isEmpty(data1)){
  1101 + data1=new ArrayList<>();
  1102 + }
  1103 + data1.add(value);
  1104 + data.put(deptName,data1);
  1105 + }
  1106 + }
  1107 + ExcelUtil.toExcelRegion(out,params ,data, cnames);
  1108 + }
  1109 + } catch (IOException e) {
  1110 + ExceptionUtils.catchException(e, e.getMessage());
  1111 + }
  1112 + }
  1113 + }
  1114 +
  1115 + *//**
  1116 + * 挂号信息同步
  1117 + * @param authorization
  1118 + * @param doctor
  1119 + * @param date
  1120 + * @return
  1121 + *//*
  1122 + @RequestMapping(method = RequestMethod.GET, value = "/dt/sync/appointment")
  1123 + @ResponseBody
  1124 + public BaseResponse syncAppointmentList(@RequestHeader("Authorization")String authorization,
  1125 + @RequestParam(required = true) String doctor,
  1126 + @RequestParam(required = true) String date){
  1127 + if (!authorization.contains(Authorization)){
  1128 + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常");
  1129 + }
  1130 + Map<String,String> params=new HashMap<>();
  1131 + if (doctors.contains(doctor)){
  1132 + doctor="孙慧洁";
  1133 + }
  1134 + params.put("doctor",doctor);
  1135 + params.put("ksrq",date);
  1136 + params.put("jsrq",date);
  1137 + HttpClientUtil.doGet("http://192.168.5.23:9090/dtdyrm/getdtAppointment" ,params,"utf-8",null);
  1138 + return new BaseResponse();
  1139 + }
  1140 + @Autowired
  1141 + private IdtdyrmFmService idtdyrmFmService;
  1142 + //导出
  1143 + @ResponseBody
  1144 + @RequestMapping(value = "/dt/appointment/export", method = RequestMethod.GET)
  1145 + public void reportFmRecord(@RequestHeader("Authorization")String authorization,
  1146 + @RequestParam String doctor,
  1147 + @RequestParam String startTime,
  1148 + @RequestParam String endTime,
  1149 + @RequestParam(required = false) String name,
  1150 + @RequestParam(required = false) String doctorName,
  1151 + HttpServletResponse response) {
  1152 + if (!authorization.contains(Authorization)){
  1153 + throw new RuntimeException("权限异常");
  1154 + }
  1155 + if (doctors.contains(doctor)){
  1156 + doctor="孙慧洁";
  1157 + }
  1158 + idtdyrmFmService.reportAppointmentList(response,doctor,startTime,endTime,name,doctorName);
  1159 + }
  1160 +
  1161 +
  1162 +
  1163 + @RequestMapping(method = RequestMethod.GET, value = "/pc/pregnancy")
  1164 + @ResponseBody
  1165 + public String getPregnancyList( String page,
  1166 + String limit,
  1167 + String phone,
  1168 + String days,
  1169 + String type,
  1170 + String categoryId){
  1171 +
  1172 + Map<String,String> params=new HashMap<>();
  1173 + params.put("page",page);
  1174 + params.put("limit",limit);
  1175 + params.put("phone",phone);
  1176 + params.put("days",days);
  1177 + String str;
  1178 + if ("4312".equals(categoryId) ){
  1179 + str= HttpClientUtil.doGet(MEMBER_BABY_URL+"/wx/pc/riskGuide" ,params,"utf-8",null);
  1180 + }else {
  1181 + params.put("categoryId",categoryId);
  1182 + params.put("type",type);
  1183 + str= HttpClientUtil.doGet(MEMBER_BABY_URL+"/wx/pc/articles/precise" ,params,"utf-8",null);
  1184 + }
  1185 + return str;
  1186 + }*/
  1187 +}