1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- package thyyxxk.webserver.utils;
- import org.springframework.web.client.RestTemplate;
- import thyyxxk.webserver.config.exception.ExceptionEnum;
- import thyyxxk.webserver.constants.ResponceType;
- import thyyxxk.webserver.entity.ResultVo;
- import thyyxxk.webserver.entity.yibao.patient.Overview;
- import java.util.HashMap;
- import java.util.List;
- /**
- * @author dj
- */
- @SuppressWarnings("rawtypes")
- public class YibaoHttpUtil {
- private static final String HTTP_HEADER = "http://";
- public static ResultVo httpPost(String tailUrl, Object param, String responce) {
- if (ResponceType.isNoneMedicalInsurance(responce)) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "自费病人无需进行医保相关操作。");
- }
- RestTemplate restTemplate = new RestTemplate();
- if (tailUrl.startsWith(HTTP_HEADER)) {
- return restTemplate.postForObject(tailUrl, param, ResultVo.class);
- } else {
- String url = YbLinksUtil.getCompleteUrl(tailUrl, responce);
- return restTemplate.postForObject(url, param, ResultVo.class);
- }
- }
- public static ResultVo equalizeUpload(String linkKey, String mode,
- List<Overview> listParam,
- Overview singleParam, String responce) {
- ResultVo resultVo = null;
- String[] links = YbLinksUtil.uploadLinks.get(linkKey);
- int count = 0;
- for (String link : links) {
- if (null == listParam) {
- resultVo = httpPost(link + mode, singleParam, responce);
- } else {
- resultVo = httpPost(link + mode, listParam, responce);
- }
- if (resultVo.getCode() != 10) {
- break;
- } else {
- count += 1;
- if (null != resultVo.getData()) {
- if (null == listParam) {
- if (resultVo.getData().toString().equals(singleParam.getInpatientNo())) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "住院号【" + singleParam.getInpatientNo() + "】的患者正在其他进程上传,请勿操作。");
- }
- } else {
- List<HashMap<String, String>> list = FilterUtil.cast(resultVo.getData());
- StringBuilder builder = new StringBuilder("【");
- for (HashMap<String, String> item : list) {
- for (Overview item2 : listParam) {
- if (item.get("inpatientNo").equals(item2.getInpatientNo())) {
- builder.append(item2.getInpatientNo()).append(",");
- }
- }
- }
- builder.append("】");
- String msg = builder.toString();
- if (!"【】".equals(msg)) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "住院号" + msg + "的患者正在其他进程上传,请取消对应的勾选后再进行操作。");
- }
- }
- }
- }
- }
- if (count == 3) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "所有上传进程均被占用,请稍后再试。");
- }
- return resultVo;
- }
- }
|