| | |
| | | package com.ruoyi.quartz.task; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.JsonNode; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.common.reflect.TypeToken; |
| | | import com.google.gson.JsonObject; |
| | | import com.google.gson.JsonArray; |
| | | import com.google.gson.Gson; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.enums.ServiceFromEnum; |
| | | import com.ruoyi.common.utils.RSAPublicKeyExample; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.http.HttpUtils; |
| | | import com.smartor.common.SendService; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.mapper.ServiceSubtaskMapper; |
| | | import com.smartor.mapper.ServiceTaskMapper; |
| | | import com.smartor.service.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.apache.commons.lang3.math.NumberUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.lang.reflect.Type; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | IBaseSmsaccountService baseSmsaccountService; |
| | | |
| | | @Autowired |
| | | IPatArchiveService patArchiveService; |
| | | |
| | | @Autowired |
| | | IPatMedInhospService patMedInhospService; |
| | | |
| | | @Autowired |
| | | IPatMedOuthospService patMedOuthospService; |
| | | |
| | | @Value("${hosp_info_url}") |
| | | private String hospInfoUrl; |
| | | |
| | | public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) { |
| | | System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i)); |
| | | } |
| | |
| | | */ |
| | | public void dealHisData() { |
| | | //将患者信息、出院、门诊数据全部采集 |
| | | |
| | | getInHospInfo("0"); |
| | | getInHospInfo("1"); |
| | | |
| | | //调用dealOupHospInfo数据处理方法,处理完后,将“出院表的check_flag=1” |
| | | //获取当前日期 (精确到天)往前推相应天数(在指定的基础模板中找对应的天数), |
| | |
| | | List<ServiceTask> serviceTasks = serviceTaskMapper.selectServiceTaskList(st); |
| | | for (ServiceTask serviceTask : serviceTasks) { |
| | | //通过taskId,获取未执行的子任务信息 |
| | | ServiceSubtask serviceSubtask = new ServiceSubtask(); |
| | | ServiceSubtaskVO serviceSubtask = new ServiceSubtaskVO(); |
| | | serviceSubtask.setTaskid(serviceTask.getTaskid()); |
| | | serviceSubtask.setSendstate(2L); |
| | | List<ServiceSubtask> selectServiceSubtaskList = iServiceSubtaskService.selectServiceSubtaskList(serviceSubtask); |
| | |
| | | String descByCode = ServiceFromEnum.getDescByCode(Integer.valueOf(serviceFrom)); |
| | | //这里可以考虑用策略模式优化一下,不然太难看了 |
| | | //通过任务ID拿到患者信息 |
| | | ServiceSubtask ivrTaskcall = new ServiceSubtask(); |
| | | ServiceSubtaskVO ivrTaskcall = new ServiceSubtaskVO(); |
| | | ivrTaskcall.setTaskid(commonTaskcallMQ.getTaskid()); |
| | | List<ServiceSubtask> selectServiceSubtaskList = iServiceSubtaskService.selectServiceSubtaskList(ivrTaskcall); |
| | | if (descByCode.equals("电话")) { |
| | |
| | | if (commonTaskcallMQ.getSendType().equals("2")) { |
| | | //说明是立即发送 |
| | | String value = redisCache.getCacheObject("cache-0"); |
| | | ServiceSubtask serviceSubtask1 = new ServiceSubtask(); |
| | | ServiceSubtaskVO serviceSubtask1 = new ServiceSubtaskVO(); |
| | | serviceSubtask1.setTaskid(commonTaskcallMQ.getTaskid()); |
| | | List<ServiceSubtask> selectServiceSubtaskList1 = iServiceSubtaskService.selectServiceSubtaskList(serviceSubtask1); |
| | | for (ServiceSubtask serviceSubtask2 : selectServiceSubtaskList1) { |
| | |
| | | } else { |
| | | //非立即发送 |
| | | String value = redisCache.getCacheObject(key); |
| | | ServiceSubtask serviceSubtask1 = new ServiceSubtask(); |
| | | ServiceSubtaskVO serviceSubtask1 = new ServiceSubtaskVO(); |
| | | serviceSubtask1.setTaskid(commonTaskcallMQ.getTaskid()); |
| | | List<ServiceSubtask> selectServiceSubtaskList1 = iServiceSubtaskService.selectServiceSubtaskList(serviceSubtask1); |
| | | for (ServiceSubtask serviceSubtask2 : selectServiceSubtaskList1) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获出院患者信息 |
| | | * cry 出入院: 0 入院 1 出院 |
| | | */ |
| | | private void getInHospInfo(String cry) { |
| | | // 获取当前日期和时间 |
| | | LocalDateTime currentDateTime = LocalDateTime.now(); |
| | | // 获取前一天的日期和时间 |
| | | LocalDateTime previousDateTime = currentDateTime.minusDays(1); |
| | | // 定义日期时间格式 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S"); |
| | | Map<String, String> req = new HashMap<>(); |
| | | if (cry.equals("1")) { |
| | | req.put("startTime", previousDateTime.format(formatter)); |
| | | req.put("endTime", currentDateTime.format(formatter)); |
| | | req.put("currStatus", "4"); |
| | | } else if (cry.equals("0")) { |
| | | req.put("admissStartDate", previousDateTime.format(formatter)); |
| | | req.put("admissEndDate", currentDateTime.format(formatter)); |
| | | req.put("currStatus", "2"); |
| | | } |
| | | Map<String, String> header = new HashMap<>(); |
| | | header.put("x-hcsb-serviceno", "IS002347"); |
| | | header.put("x-hcsb-version", "2.0"); |
| | | header.put("x-hcsb-sourcesyscode", "14"); |
| | | header.put("x-hcsb-token", "ArGE2JnHtxG/Zx5nrnGY4eOfMUJGGJokAJHigG1BrCY="); |
| | | header.put("x-hcsb-msgdate", currentDateTime.format(formatter)); |
| | | String result = HttpUtils.sendPostByHeader(hospInfoUrl, new Gson().toJson(req), header); |
| | | //数据解析 |
| | | Gson gson = new Gson(); |
| | | JsonObject jsonObject = gson.fromJson(result, JsonObject.class); |
| | | JsonArray resultArray = jsonObject.getAsJsonObject("data").getAsJsonArray("result"); |
| | | Type resultType = new TypeToken<List<ThiedInhospInfo>>() { |
| | | }.getType(); |
| | | List<ThiedInhospInfo> thiedInhospInfoList = gson.fromJson(resultArray, resultType); |
| | | if (CollectionUtils.isNotEmpty(thiedInhospInfoList)) { |
| | | for (ThiedInhospInfo thiedInhospInfo : thiedInhospInfoList) { |
| | | //通过身份证号查询该患者在患者表是否存在 |
| | | PatArchive patArchive = new PatArchive(); |
| | | patArchive.setIdcardno(thiedInhospInfo.getPatiIdCardNo()); |
| | | List<PatArchive> patArchives = patArchiveService.selectPatArchiveList(patArchive); |
| | | if (CollectionUtils.isEmpty(patArchives)) { |
| | | patArchive.setPatientno(thiedInhospInfo.getPatiMediaNo()); |
| | | patArchive.setSourcefrom(2); |
| | | patArchive.setPattype("2"); |
| | | patArchive.setSex(thiedInhospInfo.getPatiRecordGender().equals("男") ? 1L : 2L); |
| | | patArchive.setNation(thiedInhospInfo.getPatiNation()); |
| | | patArchive.setNativePlace(thiedInhospInfo.getPatiNationality()); |
| | | patArchive.setPlaceOfResidence(thiedInhospInfo.getPatiHomeAddr()); |
| | | try { |
| | | if (StringUtils.isNotEmpty(thiedInhospInfo.getPatiBirthday())) |
| | | patArchive.setBirthdate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(thiedInhospInfo.getPatiBirthday())); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | String age = thiedInhospInfo.getAge().replaceAll("岁", ""); |
| | | boolean creatable = NumberUtils.isCreatable(age); |
| | | if (creatable) patArchive.setAge(StringUtils.isNotEmpty(age) ? Long.valueOf(age) : null); |
| | | patArchive.setTelcode(thiedInhospInfo.getCompanyTelNum()); |
| | | patArchive.setRelativetelcode(thiedInhospInfo.getContactPersonPhone()); |
| | | patArchive.setDelFlag("0"); |
| | | patArchive.setCreateTime(new Date()); |
| | | patArchive.setUpdateTime(new Date()); |
| | | patArchive.setName(thiedInhospInfo.getPatiRecordName()); |
| | | patArchiveService.insertPatArchive(patArchive); |
| | | } |
| | | PatMedInhosp patMedInhosp = new PatMedInhosp(); |
| | | patMedInhosp.setPatid(patArchive.getId()); |
| | | patMedInhosp.setPatno(patArchive.getPatientno()); |
| | | patMedInhosp.setPatname(patArchive.getName()); |
| | | patMedInhosp.setSerialnum(thiedInhospInfo.getInpatientId()); |
| | | if (cry.equals("0")) { |
| | | patMedInhosp.setInhospstate("0"); |
| | | } else if (cry.equals("1")) { |
| | | patMedInhosp.setInhospstate("1"); |
| | | } |
| | | patMedInhosp.setHospitalcode(thiedInhospInfo.getAreaId()); |
| | | patMedInhosp.setIcd10code(thiedInhospInfo.getDiagIcd10()); |
| | | patMedInhosp.setDiagname(thiedInhospInfo.getDiagName()); |
| | | try { |
| | | if (StringUtils.isNotEmpty(thiedInhospInfo.getAdmissDate())) |
| | | patMedInhosp.setStarttime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(thiedInhospInfo.getAdmissDate())); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | try { |
| | | if (StringUtils.isNotEmpty(thiedInhospInfo.getOutDate())) |
| | | patMedInhosp.setEndtime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(thiedInhospInfo.getOutDate())); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | patMedInhosp.setDeptcode(thiedInhospInfo.getAdmissDeptId()); |
| | | patMedInhosp.setDeptid(thiedInhospInfo.getAdmissDeptId()); |
| | | patMedInhosp.setDeptname(thiedInhospInfo.getAdmissDeptName()); |
| | | patMedInhosp.setBedNo(thiedInhospInfo.getAdmissBedNo()); |
| | | patMedInhosp.setDelFlag("0"); |
| | | patMedInhosp.setLeaveldeptcode(thiedInhospInfo.getCurrWardId()); |
| | | patMedInhosp.setLeaveldeptname(thiedInhospInfo.getCurrWardName()); |
| | | patMedInhosp.setLeavediagname(thiedInhospInfo.getDiagName()); |
| | | patMedInhosp.setLeaveicd10code(thiedInhospInfo.getDiagIcd10()); |
| | | patMedInhosp.setDrname(thiedInhospInfo.getDoctName()); |
| | | if (cry.equals("0")) { |
| | | patMedInhosp.setSchemestatus(1L); |
| | | } else if (cry.equals("1")) { |
| | | patMedInhosp.setSchemestatus(2L); |
| | | } |
| | | patMedInhosp.setLeavehospitaldistrictcode(thiedInhospInfo.getCurrWardId()); |
| | | patMedInhosp.setLeavehospitaldistrictid(thiedInhospInfo.getCurrWardId()); |
| | | patMedInhosp.setLeavehospitaldistrictname(thiedInhospInfo.getCurrWardName()); |
| | | patMedInhosp.setLeaveldeptid(thiedInhospInfo.getCurrDeptId()); |
| | | patMedInhospService.insertPatMedInhosp(patMedInhosp); |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | private String getKey() { |
| | | Map<String, String> map = new HashMap<>(); |
| | | for (int i = 0; i < 6; i++) { |