Commit 6e41d703120efc08427451834c744fb07d47b93f
1 parent
0bb6236ca5
Exists in
master
and in
1 other branch
his对接患者逻辑,及新加HIS患者列表
Showing 9 changed files with 839 additions and 211 deletions
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/aop/ValidatedExceptionHandler.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/LymsHisInfoController.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsHisInfo.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsHisInfoService.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsHisInfoServiceImpl.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/GetPatientInfoTask.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/BeanUtils.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/StringUtil.java
- talkonlineweb/src/main/resources/mapper/LymsHisInfoMapper.xml
talkonlineweb/src/main/java/com/lyms/talkonlineweb/aop/ValidatedExceptionHandler.java
View file @
6e41d70
| 1 | +package com.lyms.talkonlineweb.aop; | |
| 2 | + | |
| 3 | +import com.lyms.talkonlineweb.result.BaseResponse; | |
| 4 | +import lombok.extern.log4j.Log4j2; | |
| 5 | +import org.springframework.web.bind.annotation.ControllerAdvice; | |
| 6 | + | |
| 7 | +import org.springframework.http.HttpStatus; | |
| 8 | +import org.springframework.validation.BindingResult; | |
| 9 | +import org.springframework.validation.FieldError; | |
| 10 | +import org.springframework.validation.ObjectError; | |
| 11 | +import org.springframework.web.bind.MethodArgumentNotValidException; | |
| 12 | +import org.springframework.web.bind.annotation.ExceptionHandler; | |
| 13 | +import org.springframework.web.bind.annotation.ResponseBody; | |
| 14 | +import org.springframework.web.bind.annotation.ResponseStatus; | |
| 15 | +import java.util.List; | |
| 16 | + | |
| 17 | +@Log4j2 | |
| 18 | +@ControllerAdvice | |
| 19 | +public class ValidatedExceptionHandler { | |
| 20 | + /** | |
| 21 | + * 处理@Validated参数校验失败异常 | |
| 22 | + * @param exception 异常类 | |
| 23 | + * @return 响应 | |
| 24 | + */ | |
| 25 | + @ResponseBody | |
| 26 | + @ResponseStatus(HttpStatus.BAD_REQUEST) | |
| 27 | + @ExceptionHandler(MethodArgumentNotValidException.class) | |
| 28 | + public BaseResponse exceptionHandler(MethodArgumentNotValidException exception){ | |
| 29 | + BindingResult result = exception.getBindingResult(); | |
| 30 | + StringBuilder stringBuilder = new StringBuilder(); | |
| 31 | + if (result.hasErrors()) { | |
| 32 | + List<ObjectError> errors = result.getAllErrors(); | |
| 33 | + if (errors != null) { | |
| 34 | + errors.forEach(p -> { | |
| 35 | + FieldError fieldError = (FieldError) p; | |
| 36 | + log.warn("Bad Request Parameters: dto entity [{}],field [{}],message [{}]",fieldError.getObjectName(), fieldError.getField(), fieldError.getDefaultMessage()); | |
| 37 | + stringBuilder.append(fieldError.getDefaultMessage()+";"); | |
| 38 | + }); | |
| 39 | + } | |
| 40 | + } | |
| 41 | + BaseResponse baseResponse=new BaseResponse(); | |
| 42 | + baseResponse.setErrorcode(1); | |
| 43 | + baseResponse.setErrormsg(stringBuilder.toString()); | |
| 44 | + return baseResponse; | |
| 45 | + } | |
| 46 | + | |
| 47 | +} |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/LymsHisInfoController.java
View file @
6e41d70
| 1 | +package com.lyms.talkonlineweb.controller; | |
| 2 | + | |
| 3 | +import com.baomidou.mybatisplus.core.conditions.Wrapper; | |
| 4 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
| 5 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
| 6 | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |
| 7 | +import com.lyms.talkonlineweb.domain.LymsDict; | |
| 8 | +import com.lyms.talkonlineweb.domain.LymsHisInfo; | |
| 9 | +import com.lyms.talkonlineweb.result.BaseResponse; | |
| 10 | +import com.lyms.talkonlineweb.service.LymsHisInfoService; | |
| 11 | +import com.lyms.talkonlineweb.util.StringUtil; | |
| 12 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 13 | +import org.springframework.validation.BindingResult; | |
| 14 | +import org.springframework.validation.annotation.Validated; | |
| 15 | +import org.springframework.web.bind.annotation.*; | |
| 16 | + | |
| 17 | +import java.util.List; | |
| 18 | + | |
| 19 | +/** | |
| 20 | + * 医院his对接 | |
| 21 | + */ | |
| 22 | +@RestController | |
| 23 | +@RequestMapping("his") | |
| 24 | +public class LymsHisInfoController { | |
| 25 | + | |
| 26 | + @Autowired | |
| 27 | + private LymsHisInfoService lymsHisInfoService; | |
| 28 | + | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 获取医院患者列表 | |
| 32 | + * @param hisInfo | |
| 33 | + * @return | |
| 34 | + */ | |
| 35 | + @GetMapping("getHisInfo") | |
| 36 | + public BaseResponse getHisInfo(LymsHisInfo hisInfo, int current, int size){ | |
| 37 | + BaseResponse baseResponse=new BaseResponse(); | |
| 38 | + Page<LymsHisInfo> page=new Page<>(current,size); | |
| 39 | + QueryWrapper<LymsHisInfo> query=new QueryWrapper(); | |
| 40 | + query.orderByDesc("createdtime"); | |
| 41 | + if(null!=hisInfo.getUpType()){ | |
| 42 | + query.eq("up_type", hisInfo.getUpType()); | |
| 43 | + } | |
| 44 | + if(StringUtil.isNotEmpty(hisInfo.getSynthesisQuery())){ | |
| 45 | + query.and(wrapper -> wrapper .like("name", hisInfo.getName()) | |
| 46 | + .or().eq("phone", hisInfo.getPhone()) | |
| 47 | + .or().eq("idCard", hisInfo.getIdcard())); | |
| 48 | + } | |
| 49 | + if(null!=hisInfo.getStartCreatedtime()){ | |
| 50 | + query.ge("createdtime", hisInfo.getStartCreatedtime()); | |
| 51 | + } | |
| 52 | + if(null!=hisInfo.getEndCreatedtime()){ | |
| 53 | + query.le("createdtime", hisInfo.getEndCreatedtime()); | |
| 54 | + } | |
| 55 | + Page<LymsHisInfo> hisInfoPage=lymsHisInfoService.page(page,query); | |
| 56 | + baseResponse.setObject(hisInfoPage); | |
| 57 | + return baseResponse; | |
| 58 | + } | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * 上传his患者信息 | |
| 62 | + * @param lymsHisInfo | |
| 63 | + * @return | |
| 64 | + */ | |
| 65 | + @PostMapping("upHisInfo") | |
| 66 | + public BaseResponse upHisInfo( @RequestBody @Validated LymsHisInfo lymsHisInfo){ | |
| 67 | + BaseResponse baseResponse=new BaseResponse(); | |
| 68 | + String result = lymsHisInfoService.upHisInfo(lymsHisInfo); | |
| 69 | + if(StringUtil.isNotEmpty(result)){ | |
| 70 | + baseResponse.setErrorcode(1); | |
| 71 | + baseResponse.setErrormsg(result); | |
| 72 | + }else { | |
| 73 | + lymsHisInfo.setUpType(1); | |
| 74 | + final boolean b = lymsHisInfoService.updateById(lymsHisInfo); | |
| 75 | + if(b){ | |
| 76 | + baseResponse.setErrorcode(0); | |
| 77 | + baseResponse.setErrormsg("患者上传成功"); | |
| 78 | + } | |
| 79 | + } | |
| 80 | + return baseResponse; | |
| 81 | + } | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | +} |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsHisInfo.java
View file @
6e41d70
| 1 | +package com.lyms.talkonlineweb.domain; | |
| 2 | + | |
| 3 | +import com.baomidou.mybatisplus.annotation.*; | |
| 4 | + | |
| 5 | +import java.io.Serializable; | |
| 6 | +import java.util.Date; | |
| 7 | +import lombok.Data; | |
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | + | |
| 10 | +import javax.validation.constraints.NotNull; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 对接医院his获取患者信息 | |
| 14 | + * @TableName lyms_his_info | |
| 15 | + */ | |
| 16 | +@TableName(value ="lyms_his_info") | |
| 17 | +@Data | |
| 18 | +public class LymsHisInfo implements Serializable { | |
| 19 | + /** | |
| 20 | + * | |
| 21 | + */ | |
| 22 | + @TableId(value = "id", type = IdType.AUTO) | |
| 23 | + @NotNull(message = "id不能为空") | |
| 24 | + private Integer id; | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 编号 | |
| 28 | + */ | |
| 29 | + @TableField(value = "vcCardNo") | |
| 30 | + @NotNull(message = "vccardno不能为空") | |
| 31 | + private String vccardno; | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 患者姓名 | |
| 35 | + */ | |
| 36 | + @TableField(value = "name") | |
| 37 | + @NotNull(message = "name不能为空") | |
| 38 | + private String name; | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * 性别 | |
| 42 | + */ | |
| 43 | + @TableField(value = "sex") | |
| 44 | + @NotNull(message = "sex不能为空") | |
| 45 | + private String sex; | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * 生日 | |
| 49 | + */ | |
| 50 | + @TableField(value = "birthday") | |
| 51 | + @NotNull(message = "birthday不能为空") | |
| 52 | + private String birthday; | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 电话 | |
| 56 | + */ | |
| 57 | + @TableField(value = "phone") | |
| 58 | + @NotNull(message = "phone不能为空") | |
| 59 | + private String phone; | |
| 60 | + | |
| 61 | + /** | |
| 62 | + * 身份证号码 | |
| 63 | + */ | |
| 64 | + @TableField(value = "idCard") | |
| 65 | + @NotNull(message = "idcard不能为空") | |
| 66 | + private String idcard; | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * 科室名称 | |
| 70 | + */ | |
| 71 | + @TableField(value = "dept") | |
| 72 | + @NotNull(message = "dept不能为空") | |
| 73 | + private String dept; | |
| 74 | + | |
| 75 | + /** | |
| 76 | + * 疾病名称 | |
| 77 | + */ | |
| 78 | + @TableField(value = "diagnose") | |
| 79 | + @NotNull(message = "diagnose不能为空") | |
| 80 | + private String diagnose; | |
| 81 | + | |
| 82 | + /** | |
| 83 | + * 医生姓名 | |
| 84 | + */ | |
| 85 | + @TableField(value = "doctor") | |
| 86 | + @NotNull(message = "doctor不能为空") | |
| 87 | + private String doctor; | |
| 88 | + | |
| 89 | + /** | |
| 90 | + * 上传问诊平台状态。0:未上传 1:已上传 | |
| 91 | + */ | |
| 92 | + @TableField(value = "up_type") | |
| 93 | + @NotNull(message = "upType不能为空") | |
| 94 | + private Integer upType; | |
| 95 | + | |
| 96 | + /** | |
| 97 | + * 上传时间 | |
| 98 | + */ | |
| 99 | + @TableField(value = "up_time",fill = FieldFill.UPDATE) | |
| 100 | + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |
| 101 | + private Date upTime; | |
| 102 | + | |
| 103 | + /** | |
| 104 | + * 创建时间 | |
| 105 | + */ | |
| 106 | + @TableField(value = "createdtime",fill = FieldFill.INSERT) | |
| 107 | + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |
| 108 | + @NotNull(message = "createdtime不能为空") | |
| 109 | + private Date createdtime; | |
| 110 | + /** | |
| 111 | + * 筛选开始时间 | |
| 112 | + */ | |
| 113 | + private Date startCreatedtime; | |
| 114 | + /** | |
| 115 | + * 筛选结束时间 | |
| 116 | + */ | |
| 117 | + private Date endCreatedtime; | |
| 118 | + /** | |
| 119 | + * 综合查询(姓名/电话/身份证) | |
| 120 | + */ | |
| 121 | + private String synthesisQuery; | |
| 122 | + | |
| 123 | + @TableField(exist = false) | |
| 124 | + private static final long serialVersionUID = 1L; | |
| 125 | + | |
| 126 | + @Override | |
| 127 | + public boolean equals(Object that) { | |
| 128 | + if (this == that) { | |
| 129 | + return true; | |
| 130 | + } | |
| 131 | + if (that == null) { | |
| 132 | + return false; | |
| 133 | + } | |
| 134 | + if (getClass() != that.getClass()) { | |
| 135 | + return false; | |
| 136 | + } | |
| 137 | + LymsHisInfo other = (LymsHisInfo) that; | |
| 138 | + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) | |
| 139 | + && (this.getVccardno() == null ? other.getVccardno() == null : this.getVccardno().equals(other.getVccardno())) | |
| 140 | + && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName())) | |
| 141 | + && (this.getSex() == null ? other.getSex() == null : this.getSex().equals(other.getSex())) | |
| 142 | + && (this.getBirthday() == null ? other.getBirthday() == null : this.getBirthday().equals(other.getBirthday())) | |
| 143 | + && (this.getPhone() == null ? other.getPhone() == null : this.getPhone().equals(other.getPhone())) | |
| 144 | + && (this.getIdcard() == null ? other.getIdcard() == null : this.getIdcard().equals(other.getIdcard())) | |
| 145 | + && (this.getDept() == null ? other.getDept() == null : this.getDept().equals(other.getDept())) | |
| 146 | + && (this.getDiagnose() == null ? other.getDiagnose() == null : this.getDiagnose().equals(other.getDiagnose())) | |
| 147 | + && (this.getDoctor() == null ? other.getDoctor() == null : this.getDoctor().equals(other.getDoctor())) | |
| 148 | + && (this.getUpType() == null ? other.getUpType() == null : this.getUpType().equals(other.getUpType())) | |
| 149 | + && (this.getUpTime() == null ? other.getUpTime() == null : this.getUpTime().equals(other.getUpTime())) | |
| 150 | + && (this.getCreatedtime() == null ? other.getCreatedtime() == null : this.getCreatedtime().equals(other.getCreatedtime())); | |
| 151 | + } | |
| 152 | + | |
| 153 | + @Override | |
| 154 | + public int hashCode() { | |
| 155 | + final int prime = 31; | |
| 156 | + int result = 1; | |
| 157 | + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); | |
| 158 | + result = prime * result + ((getVccardno() == null) ? 0 : getVccardno().hashCode()); | |
| 159 | + result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); | |
| 160 | + result = prime * result + ((getSex() == null) ? 0 : getSex().hashCode()); | |
| 161 | + result = prime * result + ((getBirthday() == null) ? 0 : getBirthday().hashCode()); | |
| 162 | + result = prime * result + ((getPhone() == null) ? 0 : getPhone().hashCode()); | |
| 163 | + result = prime * result + ((getIdcard() == null) ? 0 : getIdcard().hashCode()); | |
| 164 | + result = prime * result + ((getDept() == null) ? 0 : getDept().hashCode()); | |
| 165 | + result = prime * result + ((getDiagnose() == null) ? 0 : getDiagnose().hashCode()); | |
| 166 | + result = prime * result + ((getDoctor() == null) ? 0 : getDoctor().hashCode()); | |
| 167 | + result = prime * result + ((getUpType() == null) ? 0 : getUpType().hashCode()); | |
| 168 | + result = prime * result + ((getUpTime() == null) ? 0 : getUpTime().hashCode()); | |
| 169 | + result = prime * result + ((getCreatedtime() == null) ? 0 : getCreatedtime().hashCode()); | |
| 170 | + return result; | |
| 171 | + } | |
| 172 | + | |
| 173 | + @Override | |
| 174 | + public String toString() { | |
| 175 | + StringBuilder sb = new StringBuilder(); | |
| 176 | + sb.append(getClass().getSimpleName()); | |
| 177 | + sb.append(" ["); | |
| 178 | + sb.append("Hash = ").append(hashCode()); | |
| 179 | + sb.append(", id=").append(id); | |
| 180 | + sb.append(", vccardno=").append(vccardno); | |
| 181 | + sb.append(", name=").append(name); | |
| 182 | + sb.append(", sex=").append(sex); | |
| 183 | + sb.append(", birthday=").append(birthday); | |
| 184 | + sb.append(", phone=").append(phone); | |
| 185 | + sb.append(", idcard=").append(idcard); | |
| 186 | + sb.append(", dept=").append(dept); | |
| 187 | + sb.append(", diagnose=").append(diagnose); | |
| 188 | + sb.append(", doctor=").append(doctor); | |
| 189 | + sb.append(", upType=").append(upType); | |
| 190 | + sb.append(", upTime=").append(upTime); | |
| 191 | + sb.append(", createdtime=").append(createdtime); | |
| 192 | + sb.append(", serialVersionUID=").append(serialVersionUID); | |
| 193 | + sb.append("]"); | |
| 194 | + return sb.toString(); | |
| 195 | + } | |
| 196 | +} |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsHisInfoService.java
View file @
6e41d70
| 1 | +package com.lyms.talkonlineweb.service; | |
| 2 | + | |
| 3 | +import com.lyms.talkonlineweb.domain.LymsHisInfo; | |
| 4 | +import com.baomidou.mybatisplus.extension.service.IService; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * | |
| 8 | + */ | |
| 9 | +public interface LymsHisInfoService extends IService<LymsHisInfo> { | |
| 10 | + | |
| 11 | + String upHisInfo(LymsHisInfo lymsHisInfo); | |
| 12 | +} |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsHisInfoServiceImpl.java
View file @
6e41d70
| 1 | +package com.lyms.talkonlineweb.service.impl; | |
| 2 | + | |
| 3 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
| 4 | +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; | |
| 5 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
| 6 | +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |
| 7 | +import com.lyms.talkonlineweb.domain.*; | |
| 8 | +import com.lyms.talkonlineweb.result.BaseResponse; | |
| 9 | +import com.lyms.talkonlineweb.service.*; | |
| 10 | +import com.lyms.talkonlineweb.mapper.LymsHisInfoMapper; | |
| 11 | +import com.lyms.talkonlineweb.util.Constant; | |
| 12 | +import com.lyms.talkonlineweb.util.StringUtil; | |
| 13 | +import com.lyms.talkonlineweb.util.WeiXinUtil; | |
| 14 | +import lombok.extern.log4j.Log4j2; | |
| 15 | +import org.apache.commons.lang3.StringUtils; | |
| 16 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 17 | +import org.springframework.beans.factory.annotation.Value; | |
| 18 | +import org.springframework.stereotype.Service; | |
| 19 | + | |
| 20 | +import java.util.*; | |
| 21 | + | |
| 22 | +/** | |
| 23 | + * | |
| 24 | + */ | |
| 25 | +@Service | |
| 26 | +@Log4j2 | |
| 27 | +public class LymsHisInfoServiceImpl extends ServiceImpl<LymsHisInfoMapper, LymsHisInfo> | |
| 28 | + implements LymsHisInfoService{ | |
| 29 | + | |
| 30 | + @Value("${patient.hospitalName}")//配置yml 医院名称 | |
| 31 | + public String hospitalName; | |
| 32 | + @Value("${patient.hospital}")//配置yml 医院id | |
| 33 | + public Integer hospital; | |
| 34 | + @Autowired | |
| 35 | + private LymsDictService lymsDictService; | |
| 36 | + @Autowired | |
| 37 | + private LymsPatientService lymsPatientService;//患者 | |
| 38 | + @Autowired | |
| 39 | + private LymsHdepartService lymsHdepartService;//科室 | |
| 40 | + @Autowired | |
| 41 | + private LymsDoctorService lymsDoctorService;//医生 | |
| 42 | + @Autowired | |
| 43 | + private LymsPcaseService lymsPcaseService;//病例 | |
| 44 | + @Autowired | |
| 45 | + private LymsIllnessService lymsIllnessService;//疾病 | |
| 46 | + @Autowired | |
| 47 | + private LymsTcardService lymsTcardService;//问诊卡信息 | |
| 48 | + | |
| 49 | + | |
| 50 | + @Override | |
| 51 | + public String upHisInfo(LymsHisInfo lymsHisInfo) { | |
| 52 | + return collateData(lymsHisInfo); | |
| 53 | + } | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * 处理数据,执行 | |
| 57 | +// * @param lymsHisInfo | |
| 58 | + */ | |
| 59 | + private String collateData(LymsHisInfo lymsHisInfo){ | |
| 60 | + if(null!=lymsHisInfo) { | |
| 61 | + //姓名 | |
| 62 | + String name = lymsHisInfo.getName(); | |
| 63 | + //性别 | |
| 64 | + Integer sex = null; | |
| 65 | + if("男".equals(lymsHisInfo.getSex())){ | |
| 66 | + sex=1; | |
| 67 | + }else if("女".equals(lymsHisInfo.getSex())){ | |
| 68 | + sex=2; | |
| 69 | + } | |
| 70 | + //生日 | |
| 71 | + String birthday = lymsHisInfo.getBirthday(); | |
| 72 | + //电话 | |
| 73 | + String phone = lymsHisInfo.getPhone(); | |
| 74 | + //科室 | |
| 75 | + Integer deptId = null;//科室id | |
| 76 | + String deptName = lymsHisInfo.getDept(); | |
| 77 | + LymsHdepart depart = new LymsHdepart(); | |
| 78 | + depart.setDname(deptName); | |
| 79 | + depart.setHid(hospital); | |
| 80 | + LymsHdepart lymsHdeparts = lymsHdepartService.getOne(Wrappers.query(depart)); | |
| 81 | + if (null!=lymsHdeparts) { | |
| 82 | + deptId = lymsHdeparts.getDid(); | |
| 83 | + }else { | |
| 84 | + return "医院科室不存在,请增加"+deptName; | |
| 85 | + } | |
| 86 | + //医生 | |
| 87 | + Integer doctorId = null;//医生id | |
| 88 | + String doctorName = lymsHisInfo.getDoctor(); | |
| 89 | + LymsDoctor doctor = new LymsDoctor(); | |
| 90 | + doctor.setHid(hospital); | |
| 91 | + doctor.setDpid(deptId); | |
| 92 | + doctor.setDname(doctorName); | |
| 93 | + List<LymsDoctor> lymsDoctors = lymsDoctorService.list(Wrappers.query(doctor)); | |
| 94 | + if (CollectionUtils.isNotEmpty(lymsDoctors)) { | |
| 95 | + doctorId = lymsDoctors.get(0).getDid(); | |
| 96 | + }else { | |
| 97 | + return "医生不存在,请在"+deptName+"下面增加"+doctorName+"医生!"; | |
| 98 | + } | |
| 99 | + | |
| 100 | + //疾病 | |
| 101 | + String[] diagnoses =lymsHisInfo.getDiagnose().split(","); | |
| 102 | + List<String> diagnoseIds = new ArrayList<>();//疾病ids | |
| 103 | + if (null != diagnoses) { | |
| 104 | + for (String diagnose : diagnoses) { | |
| 105 | + LymsDict dict = new LymsDict(); | |
| 106 | + dict.setVtype(3); | |
| 107 | + dict.setValue(diagnose); | |
| 108 | + List<LymsDict> dictList = lymsDictService.list(Wrappers.query(dict)); | |
| 109 | + if (CollectionUtils.isNotEmpty(dictList)) { | |
| 110 | + for (LymsDict lymsDict : dictList) { | |
| 111 | + diagnoseIds.add(lymsDict.getCode().toString()); | |
| 112 | + } | |
| 113 | + } | |
| 114 | + } | |
| 115 | + } | |
| 116 | + //如果有疾病在数据库中不存在,则都不予上传 | |
| 117 | + if(diagnoses.length-1!=diagnoseIds.size()){ | |
| 118 | + return "疾病不存在,请在设置-字典管理中添加疾病:"+lymsHisInfo.getDiagnose(); | |
| 119 | + } | |
| 120 | + //患者(身份证) | |
| 121 | + String idCard = lymsHisInfo.getIdcard(); | |
| 122 | + //判断患者是否存在 | |
| 123 | + LymsPatient patientQuery = new LymsPatient(); | |
| 124 | + patientQuery.setIdno(idCard.toLowerCase()); | |
| 125 | + LymsPatient patient = lymsPatientService.getOne(Wrappers.query(patientQuery)); | |
| 126 | + if (null != patient) { | |
| 127 | + QueryWrapper<LymsPcase> queryWrapper = new QueryWrapper<>(); | |
| 128 | + queryWrapper.eq("pid", patient.getId()); | |
| 129 | + Calendar calendar = Calendar.getInstance(); | |
| 130 | + calendar.setTime(new Date()); | |
| 131 | + calendar.set(Calendar.HOUR_OF_DAY, 00);//时 | |
| 132 | + calendar.set(Calendar.MINUTE, 00);//分 | |
| 133 | + calendar.set(Calendar.SECOND, 00);//秒 | |
| 134 | + queryWrapper.ge("createdtime", calendar.getTime()); | |
| 135 | + int count = lymsPcaseService.count(queryWrapper); | |
| 136 | + //如果今天有这个患者病例不用添加(这里防止同一天平台添加后。his有该患者病例。重复添加) | |
| 137 | + if (count != 0) { | |
| 138 | + return null; | |
| 139 | + } | |
| 140 | + } | |
| 141 | + //添加患者信息及病例 | |
| 142 | + LymsPatient patient2 = new LymsPatient(); | |
| 143 | + LymsPcase pcase = new LymsPcase(); | |
| 144 | + patient2.setPname(name); | |
| 145 | + patient2.setIdno(idCard); | |
| 146 | + patient2.setBirth(birthday); | |
| 147 | + patient2.setSex(sex); | |
| 148 | + patient2.setCcnt(0); | |
| 149 | + patient2.setCreatedby(1); | |
| 150 | + pcase.setMobile(phone); | |
| 151 | + pcase.setHid(hospital); | |
| 152 | + pcase.setHname(hospitalName); | |
| 153 | + pcase.setDid(deptId); | |
| 154 | + pcase.setDname(deptName); | |
| 155 | + pcase.setDtid(doctorId); | |
| 156 | + pcase.setDtname(doctorName); | |
| 157 | + pcase.setCreatedby(1); | |
| 158 | + String illness = StringUtils.join(Arrays.asList(diagnoseIds.toArray()), ",");//疾病ids | |
| 159 | + BaseResponse baseResponse = saveOrUpdatePatient(patient2, pcase, illness); | |
| 160 | + if (null != baseResponse && 0 == baseResponse.getErrorcode()) { | |
| 161 | + log.info(">>>>>>>>>>>>>>>患者添加成功!"); | |
| 162 | + } | |
| 163 | + } | |
| 164 | + return null; | |
| 165 | + } | |
| 166 | + | |
| 167 | + //添加修改患者方法 | |
| 168 | + public BaseResponse saveOrUpdatePatient(LymsPatient patient, LymsPcase pcase, String illness) { | |
| 169 | + BaseResponse baseResponse = new BaseResponse(); | |
| 170 | + log.info(">>>>>>>>>>>>>>>登记病例"); | |
| 171 | + baseResponse.setErrormsg(""); | |
| 172 | + patient.setIdno(patient.getIdno().toLowerCase()); | |
| 173 | + LymsPatient tmpP=new LymsPatient(); | |
| 174 | + tmpP.setIdno(patient.getIdno().toLowerCase()); | |
| 175 | + LymsPatient patient2 = lymsPatientService.getOne(Wrappers.query(tmpP).eq("idno", patient.getIdno())); | |
| 176 | + if (patient2 == null) { | |
| 177 | + patient.setCreatedtime(new Date()); | |
| 178 | + patient.setPpasswd(Constant.COMMON_PASSWD); | |
| 179 | + } else { | |
| 180 | + patient.setId(patient2.getId()); | |
| 181 | + patient.setUpdatedtime(new Date()); | |
| 182 | + patient.setCcnt(patient2.getCcnt()+ (null== patient.getCcnt()?0:patient.getCcnt())); | |
| 183 | + } | |
| 184 | + | |
| 185 | + | |
| 186 | + if (!StringUtil.isEmpty(patient.getCode())) { | |
| 187 | + patient.setOpenid(WeiXinUtil.getWxOpenId(patient.getCode())); | |
| 188 | + } | |
| 189 | + | |
| 190 | + boolean f = lymsPatientService.saveOrUpdate(patient); | |
| 191 | + | |
| 192 | +// 添加病例 | |
| 193 | + pcase.setCreatedby(patient.getCreatedby()); | |
| 194 | + pcase.setPid(patient.getId()); | |
| 195 | + pcase.setCreatedtime(new Date()); | |
| 196 | + f = lymsPcaseService.saveOrUpdate(pcase); | |
| 197 | + String[] iArr = illness.split(","); | |
| 198 | + | |
| 199 | + log.info(patient); | |
| 200 | + log.info(pcase); | |
| 201 | + | |
| 202 | + Map param = new HashMap(); | |
| 203 | + param.put("vtype",3); | |
| 204 | + List<LymsDict> dLst=lymsDictService.listByMap(param); | |
| 205 | + for (int i = 0; i < iArr.length; i++) { | |
| 206 | + LymsIllness ness = new LymsIllness(); | |
| 207 | + ness.setCreatedby(patient.getCreatedby()); | |
| 208 | + ness.setPcid(pcase.getPcid()); | |
| 209 | + ness.setIid(Integer.parseInt(iArr[i])); | |
| 210 | + ness.setCreatedtime(new Date()); | |
| 211 | + | |
| 212 | + dLst.forEach(e->{ | |
| 213 | + if(e.getCode().intValue()==ness.getIid().intValue()){ | |
| 214 | + ness.setIname(e.getValue()); | |
| 215 | + } | |
| 216 | + }); | |
| 217 | + | |
| 218 | + param.clear(); | |
| 219 | + param.put("pcid", pcase.getPcid()); | |
| 220 | + param.put("iid", iArr[i]); | |
| 221 | + List<LymsIllness> iLst = lymsIllnessService.listByMap(param); | |
| 222 | + if (iLst.size() > 0) { | |
| 223 | + ness.setId(iLst.get(0).getId()); | |
| 224 | + } | |
| 225 | + f = lymsIllnessService.saveOrUpdate(ness); | |
| 226 | + log.info(ness.toString()); | |
| 227 | + } | |
| 228 | + | |
| 229 | + Date instDate = new Date(); | |
| 230 | + //需要添加医院购买卡记录 | |
| 231 | + for (int i = 0; i < patient.getCcnt() && Objects.nonNull(patient.getCcnt()); i++) { | |
| 232 | + LymsTcard tcard = new LymsTcard(); | |
| 233 | + tcard.setCnt(1); | |
| 234 | + tcard.setPcid(pcase.getPcid()); | |
| 235 | + tcard.setPid(patient.getId()); | |
| 236 | + tcard.setFid(2); | |
| 237 | + tcard.setCreatedby(patient.getCreatedby()); | |
| 238 | + tcard.setCreatedtime(instDate); | |
| 239 | + | |
| 240 | + lymsTcardService.saveOrUpdate(tcard); | |
| 241 | + } | |
| 242 | + baseResponse.setObject(patient); | |
| 243 | + baseResponse.setErrorcode(f == true ? 0 : 1); | |
| 244 | + return baseResponse; | |
| 245 | + } | |
| 246 | + | |
| 247 | + | |
| 248 | +} |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/GetPatientInfoTask.java
View file @
6e41d70
| ... | ... | @@ -10,15 +10,17 @@ |
| 10 | 10 | import com.lyms.talkonlineweb.result.BaseResponse; |
| 11 | 11 | import com.lyms.talkonlineweb.service.*; |
| 12 | 12 | import com.lyms.talkonlineweb.util.*; |
| 13 | -//import com.sun.deploy.util.StringUtils; | |
| 14 | 13 | import lombok.extern.log4j.Log4j2; |
| 14 | +import org.apache.commons.lang3.StringUtils; | |
| 15 | 15 | import org.springframework.beans.factory.annotation.Autowired; |
| 16 | 16 | import org.springframework.beans.factory.annotation.Value; |
| 17 | 17 | import org.springframework.stereotype.Component; |
| 18 | 18 | import org.springframework.validation.BindingResult; |
| 19 | 19 | import org.springframework.validation.MapBindingResult; |
| 20 | +import org.springframework.scheduling.annotation.Scheduled; | |
| 20 | 21 | import org.w3c.dom.ls.LSInput; |
| 21 | 22 | |
| 23 | +import javax.swing.event.ListDataEvent; | |
| 22 | 24 | import java.util.*; |
| 23 | 25 | |
| 24 | 26 | import static com.lyms.talkonlineweb.util.DateUtil.YYYY_MM_DD; |
| 25 | 27 | |
| ... | ... | @@ -53,14 +55,16 @@ |
| 53 | 55 | private LymsIllnessService lymsIllnessService;//疾病 |
| 54 | 56 | @Autowired |
| 55 | 57 | private LymsTcardService lymsTcardService;//问诊卡信息 |
| 58 | + @Autowired | |
| 59 | + private LymsHisInfoService lymsHisInfoService;//问诊卡信息 | |
| 56 | 60 | |
| 57 | 61 | |
| 58 | 62 | /** |
| 59 | 63 | * 获取医院患者信息。添加到问诊平台患者信息 |
| 60 | 64 | * 10分钟执行一次 |
| 61 | 65 | */ |
| 62 | -// @Scheduled(cron = "0 */10 * * * ?") | |
| 63 | - public void getPatientInfo(){ | |
| 66 | + @Scheduled(cron = "0 */10 * * * ?") | |
| 67 | + public void getPatientInfo() throws Exception { | |
| 64 | 68 | //每次执行时间范围是上一个小时 |
| 65 | 69 | String param = collateTime(); |
| 66 | 70 | if (StringUtil.isNotEmpty(param)) { |
| ... | ... | @@ -72,9 +76,26 @@ |
| 72 | 76 | List<Map<String, Object>> listMap = (List<Map<String, Object>>) resultMap.get("patients"); |
| 73 | 77 | if (CollectionUtils.isNotEmpty(listMap)) { |
| 74 | 78 | for (Map<String, Object> map : listMap) { |
| 75 | - | |
| 76 | - //处理数据 | |
| 77 | - collateData(map); | |
| 79 | + //添加到数据后续页面处理 | |
| 80 | + LymsHisInfo hisInfoMap = (LymsHisInfo) BeanUtils.mapToObject(map, LymsHisInfo.class);//map转对象 | |
| 81 | + if (null != hisInfoMap) { | |
| 82 | + //今天添加过不需要重复添加 | |
| 83 | + QueryWrapper qurey = new QueryWrapper(); | |
| 84 | + qurey.eq("idCard", hisInfoMap.getIdcard()); | |
| 85 | + qurey.eq("diagnose", hisInfoMap.getDiagnose()); | |
| 86 | + Calendar calendar = Calendar.getInstance(); | |
| 87 | + calendar.setTime(new Date()); | |
| 88 | + calendar.set(Calendar.HOUR_OF_DAY, 00);//时 | |
| 89 | + calendar.set(Calendar.MINUTE, 00);//分 | |
| 90 | + calendar.set(Calendar.SECOND, 00);//秒 | |
| 91 | + qurey.gt("createdtime", calendar.getTime()); | |
| 92 | + List<LymsHisInfo> list = lymsHisInfoService.list(qurey); | |
| 93 | + if (CollectionUtils.isEmpty(list)) { | |
| 94 | + hisInfoMap.setBirthday(StringUtil.isNotEmpty(hisInfoMap.getBirthday()) ? StringUtil.leftTruncate(hisInfoMap.getBirthday(), ' ') : null); | |
| 95 | + hisInfoMap.setUpType(0);//默认未上传 | |
| 96 | + lymsHisInfoService.save(hisInfoMap); | |
| 97 | + } | |
| 98 | + } | |
| 78 | 99 | } |
| 79 | 100 | } |
| 80 | 101 | } |
| ... | ... | @@ -83,131 +104,6 @@ |
| 83 | 104 | } |
| 84 | 105 | |
| 85 | 106 | /** |
| 86 | - * //处理数据,执行 | |
| 87 | - * @param map | |
| 88 | - */ | |
| 89 | - private void collateData(Map<String,Object> map){ | |
| 90 | - String deptName="",doctorName="";//科室名称,医生名称 | |
| 91 | - String[] diagnoses=null;//疾病名称 | |
| 92 | - String name="",sex="",birthday="",phone="",idCard="";//姓名,性别,生日、电话、身份证 | |
| 93 | - List<String> diagnoseIds=new ArrayList<>();//疾病ids | |
| 94 | - Integer deptId=null;//科室id | |
| 95 | - Integer doctorId=null;//医生id | |
| 96 | - //姓名 | |
| 97 | - name=null!=map.get("name")?map.get("name").toString():null; | |
| 98 | - //性别 | |
| 99 | - sex=null!=map.get("sex")?map.get("sex").toString():null; | |
| 100 | - if("男".equals(sex)){ | |
| 101 | - sex="1"; | |
| 102 | - }else if("女".equals(sex)){ | |
| 103 | - sex="2"; | |
| 104 | - } | |
| 105 | - //生日 | |
| 106 | - birthday=null!=map.get("birthday")?map.get("birthday").toString():null; | |
| 107 | - birthday=StringUtil.leftTruncate(birthday, ' '); | |
| 108 | - //电话 | |
| 109 | - phone=null!=map.get("phone")?map.get("phone").toString():null; | |
| 110 | - //科室 | |
| 111 | - deptName=null!=map.get("dept")?map.get("dept").toString():null; | |
| 112 | - if(StringUtil.isNotEmpty(deptName)){ | |
| 113 | - LymsHdepart depart=new LymsHdepart(); | |
| 114 | - depart.setDname(deptName); | |
| 115 | - List<LymsHdepart> list=lymsHdepartService.list(Wrappers.query(depart)); | |
| 116 | - if(CollectionUtils.isNotEmpty(list)){ | |
| 117 | - deptId=list.get(0).getDid(); | |
| 118 | - } | |
| 119 | - } | |
| 120 | - //医生 | |
| 121 | - doctorName=null!=map.get("doctor")?map.get("doctor").toString():null; | |
| 122 | - LymsDoctor doctor=new LymsDoctor(); | |
| 123 | - if(StringUtil.isNotEmpty(doctorName)){ | |
| 124 | - doctor.setDname(doctorName); | |
| 125 | - List<LymsDoctor> list = lymsDoctorService.list(Wrappers.query(doctor)); | |
| 126 | - if(CollectionUtils.isNotEmpty(list)){ | |
| 127 | - doctorId=list.get(0).getDid(); | |
| 128 | - } | |
| 129 | - } | |
| 130 | - | |
| 131 | - //疾病 | |
| 132 | - diagnoses=null!=map.get("diagnose")?map.get("diagnose").toString().split(","):null; | |
| 133 | - if(null!=diagnoses){ | |
| 134 | - for (String diagnose : diagnoses) { | |
| 135 | - LymsDict dict=new LymsDict(); | |
| 136 | - dict.setVtype(3); | |
| 137 | - dict.setValue(diagnose); | |
| 138 | - List<LymsDict> dictList=lymsDictService.list(Wrappers.query(dict)); | |
| 139 | - if(CollectionUtils.isNotEmpty(dictList)){ | |
| 140 | - for (LymsDict lymsDict : dictList) { | |
| 141 | - diagnoseIds.add(lymsDict.getCode().toString()); | |
| 142 | - } | |
| 143 | - } | |
| 144 | - } | |
| 145 | - } | |
| 146 | - | |
| 147 | - //患者(身份证) | |
| 148 | - idCard=null!=map.get("idCard")?map.get("idCard").toString():null; | |
| 149 | - if(StringUtil.isNotEmpty(idCard)){ | |
| 150 | - LymsPatient patientQuery=new LymsPatient(); | |
| 151 | - patientQuery.setIdno(idCard.toLowerCase()); | |
| 152 | - LymsPatient patient = lymsPatientService.getOne(Wrappers.query(patientQuery)); | |
| 153 | - //整理添加修改接口@PostMapping("savePatient")需要的数据 | |
| 154 | - LymsPatient patient2=new LymsPatient(); | |
| 155 | - LymsPcase pcase=new LymsPcase(); | |
| 156 | - patient2.setPname(name); | |
| 157 | - patient2.setIdno(idCard); | |
| 158 | - patient2.setBirth(birthday); | |
| 159 | - patient2.setSex(Integer.parseInt(sex)); | |
| 160 | - patient2.setCcnt(0); | |
| 161 | - patient2.setCreatedby(1); | |
| 162 | - pcase.setMobile(phone); | |
| 163 | - pcase.setHid(hospital); | |
| 164 | - pcase.setHname(hospitalName); | |
| 165 | - pcase.setDid(deptId); | |
| 166 | - pcase.setDname(deptName); | |
| 167 | - pcase.setDtid(doctorId); | |
| 168 | - pcase.setDtname(doctorName); | |
| 169 | - pcase.setCreatedby(1); | |
| 170 | - if(null==patient){//没有该患者需要添加 | |
| 171 | - if(StringUtil.isNotEmpty(name) && StringUtil.isNotEmpty(sex) && | |
| 172 | - StringUtil.isNotEmpty(birthday) && StringUtil.isNotEmpty(phone) && | |
| 173 | - StringUtil.isNotEmpty(idCard) && CollectionUtils.isNotEmpty(diagnoseIds) && | |
| 174 | - null!=deptId && null!=doctorId){ | |
| 175 | -// String illness= StringUtils.join(Arrays.asList(diagnoseIds.toArray()), ",");//疾病ids | |
| 176 | -// BaseResponse baseResponse = saveOrUpdatePatient(patient2, pcase, illness); | |
| 177 | -// if(null!=baseResponse && 0== baseResponse.getErrorcode()){ | |
| 178 | -// log.info(">>>>>>>>>>>>>>>患者添加成功!"); | |
| 179 | -// } | |
| 180 | - } | |
| 181 | - }else { | |
| 182 | - QueryWrapper<LymsPcase> queryWrapper=new QueryWrapper<>(); | |
| 183 | - queryWrapper.eq("pid", patient.getId()); | |
| 184 | - queryWrapper.in("pid", patient.getId()); | |
| 185 | - Calendar calendar = Calendar.getInstance(); | |
| 186 | - calendar.setTime(new Date()); | |
| 187 | - calendar.set(Calendar.HOUR_OF_DAY, 00);//时 | |
| 188 | - calendar.set(Calendar.MINUTE, 00);//分 | |
| 189 | - calendar.set(Calendar.SECOND, 00);//秒 | |
| 190 | - queryWrapper.gt("createdtime", calendar.getTime()); | |
| 191 | - int count = lymsPcaseService.count(queryWrapper); | |
| 192 | - //如果今天没有这个患者病例需要添加 | |
| 193 | - if(count==0){ | |
| 194 | - if(StringUtil.isNotEmpty(name) && StringUtil.isNotEmpty(sex) && | |
| 195 | - StringUtil.isNotEmpty(birthday) && StringUtil.isNotEmpty(phone) && | |
| 196 | - StringUtil.isNotEmpty(idCard) && CollectionUtils.isNotEmpty(diagnoseIds) && | |
| 197 | - null!=deptId && null!=doctorId){ | |
| 198 | -// String illness= StringUtils.join(Arrays.asList(diagnoseIds.toArray()), ",");//疾病ids | |
| 199 | -// BaseResponse baseResponse = saveOrUpdatePatient(patient2, pcase, illness); | |
| 200 | -// if(null!=baseResponse && 0== baseResponse.getErrorcode()){ | |
| 201 | -// log.info(">>>>>>>>>>>>>>>患者添加成功!"); | |
| 202 | -// } | |
| 203 | - } | |
| 204 | - }else { | |
| 205 | - return; | |
| 206 | - } | |
| 207 | - } | |
| 208 | - } | |
| 209 | - } | |
| 210 | - /** | |
| 211 | 107 | * //整理GET请求时间 |
| 212 | 108 | * //每次执行时间范围是上一个小时 |
| 213 | 109 | * @return string param:GET请求时间参数 |
| 214 | 110 | |
| ... | ... | @@ -241,84 +137,6 @@ |
| 241 | 137 | param="start=2022-02-20+13:25:59&end=2022-02-20+14:25:59";//测试用 |
| 242 | 138 | return param; |
| 243 | 139 | } |
| 244 | - //添加修改患者方法 | |
| 245 | - public BaseResponse saveOrUpdatePatient(LymsPatient patient, LymsPcase pcase, String illness) { | |
| 246 | - BaseResponse baseResponse = new BaseResponse(); | |
| 247 | - log.info(">>>>>>>>>>>>>>>登记病例"); | |
| 248 | - baseResponse.setErrormsg(""); | |
| 249 | - patient.setIdno(patient.getIdno().toLowerCase()); | |
| 250 | - LymsPatient tmpP=new LymsPatient(); | |
| 251 | - tmpP.setIdno(patient.getIdno().toLowerCase()); | |
| 252 | - LymsPatient patient2 = lymsPatientService.getOne(Wrappers.query(tmpP).eq("idno", patient.getIdno())); | |
| 253 | - if (patient2 == null) { | |
| 254 | - patient.setCreatedtime(new Date()); | |
| 255 | - patient.setPpasswd(Constant.COMMON_PASSWD); | |
| 256 | - } else { | |
| 257 | - patient.setId(patient2.getId()); | |
| 258 | - patient.setUpdatedtime(new Date()); | |
| 259 | - patient.setCcnt(patient2.getCcnt()+ (null== patient.getCcnt()?0:patient.getCcnt())); | |
| 260 | - } | |
| 261 | 140 | |
| 262 | - | |
| 263 | - if (!StringUtil.isEmpty(patient.getCode())) { | |
| 264 | - patient.setOpenid(WeiXinUtil.getWxOpenId(patient.getCode())); | |
| 265 | - } | |
| 266 | - | |
| 267 | - boolean f = lymsPatientService.saveOrUpdate(patient); | |
| 268 | - | |
| 269 | -// 添加病例 | |
| 270 | - pcase.setCreatedby(patient.getCreatedby()); | |
| 271 | - pcase.setPid(patient.getId()); | |
| 272 | - pcase.setCreatedtime(new Date()); | |
| 273 | - f = lymsPcaseService.saveOrUpdate(pcase); | |
| 274 | - String[] iArr = illness.split(","); | |
| 275 | - | |
| 276 | - log.info(patient); | |
| 277 | - log.info(pcase); | |
| 278 | - | |
| 279 | - Map param = new HashMap(); | |
| 280 | - param.put("vtype",3); | |
| 281 | - List<LymsDict> dLst=lymsDictService.listByMap(param); | |
| 282 | - for (int i = 0; i < iArr.length; i++) { | |
| 283 | - LymsIllness ness = new LymsIllness(); | |
| 284 | - ness.setCreatedby(patient.getCreatedby()); | |
| 285 | - ness.setPcid(pcase.getPcid()); | |
| 286 | - ness.setIid(Integer.parseInt(iArr[i])); | |
| 287 | - ness.setCreatedtime(new Date()); | |
| 288 | - | |
| 289 | - dLst.forEach(e->{ | |
| 290 | - if(e.getCode().intValue()==ness.getIid().intValue()){ | |
| 291 | - ness.setIname(e.getValue()); | |
| 292 | - } | |
| 293 | - }); | |
| 294 | - | |
| 295 | - param.clear(); | |
| 296 | - param.put("pcid", pcase.getPcid()); | |
| 297 | - param.put("iid", iArr[i]); | |
| 298 | - List<LymsIllness> iLst = lymsIllnessService.listByMap(param); | |
| 299 | - if (iLst.size() > 0) { | |
| 300 | - ness.setId(iLst.get(0).getId()); | |
| 301 | - } | |
| 302 | - f = lymsIllnessService.saveOrUpdate(ness); | |
| 303 | - log.info(ness.toString()); | |
| 304 | - } | |
| 305 | - | |
| 306 | - Date instDate = new Date(); | |
| 307 | - //需要添加医院购买卡记录 | |
| 308 | - for (int i = 0; i < patient.getCcnt() && Objects.nonNull(patient.getCcnt()); i++) { | |
| 309 | - LymsTcard tcard = new LymsTcard(); | |
| 310 | - tcard.setCnt(1); | |
| 311 | - tcard.setPcid(pcase.getPcid()); | |
| 312 | - tcard.setPid(patient.getId()); | |
| 313 | - tcard.setFid(2); | |
| 314 | - tcard.setCreatedby(patient.getCreatedby()); | |
| 315 | - tcard.setCreatedtime(instDate); | |
| 316 | - | |
| 317 | - lymsTcardService.saveOrUpdate(tcard); | |
| 318 | - } | |
| 319 | - baseResponse.setObject(patient); | |
| 320 | - baseResponse.setErrorcode(f == true ? 0 : 1); | |
| 321 | - return baseResponse; | |
| 322 | - } | |
| 323 | 141 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/BeanUtils.java
View file @
6e41d70
| 1 | +package com.lyms.talkonlineweb.util; | |
| 2 | + | |
| 3 | +import com.alibaba.fastjson.JSONObject; | |
| 4 | + | |
| 5 | +import java.beans.BeanInfo; | |
| 6 | +import java.beans.Introspector; | |
| 7 | +import java.beans.PropertyDescriptor; | |
| 8 | +import java.io.ByteArrayInputStream; | |
| 9 | +import java.io.ByteArrayOutputStream; | |
| 10 | +import java.io.ObjectInputStream; | |
| 11 | +import java.io.ObjectOutputStream; | |
| 12 | +import java.lang.annotation.*; | |
| 13 | +import java.lang.reflect.Array; | |
| 14 | +import java.lang.reflect.Field; | |
| 15 | +import java.lang.reflect.Method; | |
| 16 | +import java.lang.reflect.Modifier; | |
| 17 | +import java.util.HashMap; | |
| 18 | +import java.util.Map; | |
| 19 | +import java.util.Objects; | |
| 20 | + | |
| 21 | +public class BeanUtils { | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * @auther HuJiaqi | |
| 25 | + * @createTime 2016年04月07日 14时12分 | |
| 26 | + * @discription byte数组转object,建议处理异常 | |
| 27 | + */ | |
| 28 | + public static Object bytesToObject(byte[] b) { | |
| 29 | + try { | |
| 30 | + ByteArrayInputStream bis = new ByteArrayInputStream(b); | |
| 31 | + ObjectInputStream ois = new ObjectInputStream(bis); | |
| 32 | + Object obj = ois.readObject(); | |
| 33 | + ois.close(); | |
| 34 | + bis.close(); | |
| 35 | + return obj; | |
| 36 | + } catch (Exception e) { | |
| 37 | + throw new RuntimeException("byte数组转object异常", e); | |
| 38 | + } | |
| 39 | + } | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * @auther HuJiaqi | |
| 43 | + * @createTime 2016年04月07日 14时14分 | |
| 44 | + * @discription object转byte数组,建议处理异常 | |
| 45 | + */ | |
| 46 | + public static byte[] objectToBytes(Object obj) { | |
| 47 | + try { | |
| 48 | + ByteArrayOutputStream bos = new ByteArrayOutputStream(); | |
| 49 | + ObjectOutputStream oos = new ObjectOutputStream(bos); | |
| 50 | + oos.writeObject(obj); | |
| 51 | + oos.flush(); | |
| 52 | + byte[] b = bos.toByteArray(); | |
| 53 | + oos.close(); | |
| 54 | + bos.close(); | |
| 55 | + return b; | |
| 56 | + } catch (Exception e) { | |
| 57 | + throw new RuntimeException("object转byte数组异常", e); | |
| 58 | + } | |
| 59 | + } | |
| 60 | + | |
| 61 | + /** | |
| 62 | + * @auther sy | |
| 63 | + * @discription map转object,建议处理异常 | |
| 64 | + */ | |
| 65 | + //map转java对象 | |
| 66 | + public static Object mapToObject(Map<String, Object> map, Class<?> beanClass) throws Exception { | |
| 67 | + String jsonStr = JSONObject.toJSONString(map); | |
| 68 | + return JSONObject.parseObject(jsonStr, beanClass); | |
| 69 | + } | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * @auther sy | |
| 73 | + * @discription object转map,建议处理异常 | |
| 74 | + */ | |
| 75 | + public static Map<String, Object> objectToMap(Object obj) { | |
| 76 | + String jsonStr = JSONObject.toJSONString(obj); | |
| 77 | + return JSONObject.parseObject(jsonStr); | |
| 78 | + } | |
| 79 | + | |
| 80 | + | |
| 81 | + public static Map<String, Object> objectToObjectMap(Object obj) { | |
| 82 | + try { | |
| 83 | + Class c = obj.getClass(); | |
| 84 | + Map<String, Object> map = new HashMap<String, Object>(); | |
| 85 | + BeanInfo bi = Introspector.getBeanInfo(c); | |
| 86 | + PropertyDescriptor[] pds = bi.getPropertyDescriptors(); | |
| 87 | + for (PropertyDescriptor pd : pds) { | |
| 88 | + String key = pd.getName(); | |
| 89 | + if (!key.equals("class")) { | |
| 90 | + Object result = pd.getReadMethod().invoke(obj); | |
| 91 | + if (result != null) { | |
| 92 | + map.put(key, result); | |
| 93 | + } else { | |
| 94 | + map.put(key, ""); | |
| 95 | + } | |
| 96 | + } | |
| 97 | + } | |
| 98 | + return map; | |
| 99 | + } catch (Exception e) { | |
| 100 | + throw new RuntimeException("object转map异常" + e); | |
| 101 | + } | |
| 102 | + } | |
| 103 | + | |
| 104 | + /** | |
| 105 | + * @auther HuJiaqi | |
| 106 | + * @createTime 2016年04月07日 14时24分 | |
| 107 | + * @discription 修饰filed的自定义注解,用于复制bean | |
| 108 | + */ | |
| 109 | + @Target(ElementType.FIELD) | |
| 110 | + @Retention(RetentionPolicy.RUNTIME) | |
| 111 | + @Documented | |
| 112 | + public @interface CopyName { | |
| 113 | + String value() default ""; | |
| 114 | + } | |
| 115 | + | |
| 116 | + /** | |
| 117 | + * @auther HuJiaqi | |
| 118 | + * @createTime 2016年04月07日 16时33分 | |
| 119 | + * @discription 这个方法默认子类不会有与父类相同的field,没有处理这种情况 | |
| 120 | + */ | |
| 121 | + public static void copy(Object from, Object to) { | |
| 122 | + if (from == null || to == null) { | |
| 123 | + return; | |
| 124 | + } | |
| 125 | + Class c = from.getClass(); | |
| 126 | + Field[] fields = c.getDeclaredFields(); | |
| 127 | + c = c.getSuperclass(); | |
| 128 | + while (c != null) { | |
| 129 | + Field[] temp = c.getDeclaredFields(); | |
| 130 | + fields = merge(fields, temp); | |
| 131 | + c = c.getSuperclass(); | |
| 132 | + } | |
| 133 | + if (fields != null && fields.length > 0) { | |
| 134 | + for (Field fromField : fields) { | |
| 135 | + fromField.setAccessible(true); | |
| 136 | + String fieldName; | |
| 137 | + if (fromField.isAnnotationPresent(CopyName.class)) { | |
| 138 | + CopyName adjuster = fromField.getAnnotation(CopyName.class); | |
| 139 | + fieldName = !"".equals(adjuster.value()) ? adjuster.value() : fromField.getName(); | |
| 140 | + } else { | |
| 141 | + fieldName = fromField.getName(); | |
| 142 | + } | |
| 143 | + try { | |
| 144 | + Object obj = fromField.get(from); | |
| 145 | + Field toField = null; | |
| 146 | + c = to.getClass(); | |
| 147 | + while (c != null) { | |
| 148 | + try { | |
| 149 | + toField = c.getDeclaredField(fieldName); | |
| 150 | + break; | |
| 151 | + } catch (Exception e) { | |
| 152 | + c = c.getSuperclass(); | |
| 153 | + // 如果异常了,接着找父类 | |
| 154 | + } | |
| 155 | + } | |
| 156 | + if (toField != null) { | |
| 157 | + toField.setAccessible(true); | |
| 158 | + toField.set(to, obj); | |
| 159 | + } | |
| 160 | + } catch (Exception e) { | |
| 161 | + // 什么都不干,异常就当跳过了 | |
| 162 | + } | |
| 163 | + } | |
| 164 | + } | |
| 165 | + } | |
| 166 | + | |
| 167 | + /** | |
| 168 | + * @auther HuJiaqi | |
| 169 | + * @createTime 2016年04月08日 13时10分 | |
| 170 | + * @discription 数组合并,仅支持相同类型的数组合并 | |
| 171 | + */ | |
| 172 | + public static <T> T[] merge(T[] array1, T[] array2) { | |
| 173 | + if ((array1 == null) && (array2 == null)) | |
| 174 | + return null; | |
| 175 | + if ((array2 == null) || (array2.length == 0)) | |
| 176 | + return array1; | |
| 177 | + if ((array1 == null) || (array1.length == 0)) | |
| 178 | + return array2; | |
| 179 | + Class c = array1.getClass().getComponentType(); | |
| 180 | + Object[] array = (Object[]) Array.newInstance(c, array1.length + array2.length); | |
| 181 | + System.arraycopy(array1, 0, array, 0, array1.length); | |
| 182 | + System.arraycopy(array2, 0, array, array1.length, array2.length); | |
| 183 | + T[] result = (T[]) array; | |
| 184 | + return result; | |
| 185 | + } | |
| 186 | +} |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/StringUtil.java
View file @
6e41d70
| ... | ... | @@ -60,7 +60,7 @@ |
| 60 | 60 | /** |
| 61 | 61 | * 字符串截取(向左截取) |
| 62 | 62 | * @param str 原字符串 |
| 63 | - * @param chr 需要从哪个字符截取 | |
| 63 | + * @param chr 截取到哪个字符(不包含参数字符) | |
| 64 | 64 | * @return String 截取后字符串 |
| 65 | 65 | */ |
| 66 | 66 | public static String leftTruncate(String str,char chr) { |
| ... | ... | @@ -69,7 +69,7 @@ |
| 69 | 69 | char [] a = str.toCharArray(); |
| 70 | 70 | for (int i = 0; i < a.length; i++) { |
| 71 | 71 | if (a[i] == chr) { |
| 72 | - result=str.substring(0,i+1); | |
| 72 | + result=str.substring(0,i); | |
| 73 | 73 | break; |
| 74 | 74 | } |
| 75 | 75 | } |
talkonlineweb/src/main/resources/mapper/LymsHisInfoMapper.xml
View file @
6e41d70
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<!DOCTYPE mapper | |
| 3 | + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |
| 4 | + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
| 5 | +<mapper namespace="com.lyms.talkonlineweb.mapper.LymsHisInfoMapper"> | |
| 6 | + | |
| 7 | + <resultMap id="BaseResultMap" type="com.lyms.talkonlineweb.domain.LymsHisInfo"> | |
| 8 | + <id property="id" column="id" jdbcType="INTEGER"/> | |
| 9 | + <result property="vccardno" column="vcCardNo" jdbcType="VARCHAR"/> | |
| 10 | + <result property="name" column="name" jdbcType="VARCHAR"/> | |
| 11 | + <result property="sex" column="sex" jdbcType="VARCHAR"/> | |
| 12 | + <result property="birthday" column="birthday" jdbcType="VARCHAR"/> | |
| 13 | + <result property="phone" column="phone" jdbcType="VARCHAR"/> | |
| 14 | + <result property="idcard" column="idCard" jdbcType="VARCHAR"/> | |
| 15 | + <result property="dept" column="dept" jdbcType="VARCHAR"/> | |
| 16 | + <result property="diagnose" column="diagnose" jdbcType="VARCHAR"/> | |
| 17 | + <result property="doctor" column="doctor" jdbcType="VARCHAR"/> | |
| 18 | + <result property="upType" column="up_type" jdbcType="INTEGER"/> | |
| 19 | + <result property="upTime" column="up_time" jdbcType="TIMESTAMP"/> | |
| 20 | + <result property="createdtime" column="createdtime" jdbcType="TIMESTAMP"/> | |
| 21 | + </resultMap> | |
| 22 | + | |
| 23 | + <sql id="Base_Column_List"> | |
| 24 | + id,vcCardNo,name, | |
| 25 | + sex,birthday,phone, | |
| 26 | + idCard,dept,diagnose, | |
| 27 | + doctor,up_type,up_time, | |
| 28 | + createdtime | |
| 29 | + </sql> | |
| 30 | +</mapper> |