java messageutil_MessageUtil.java

package com.sunline.car.util;

import com.sunline.car.common.exception.CarServerException;

import java.util.Locale;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.context.MessageSource;

/**

* i18n消息处理工具.

*

* @author : 薛乐乐

* @since : 2019/5/5 10:47

*/

public class MessageUtil {

private static MessageSource innerMessageSource;

@Autowired

private MessageSource messageSource;

public MessageUtil() {

}

@PostConstruct

private void postConstruct() {

System.out.println("-----------" + this.messageSource);

innerMessageSource = this.messageSource;

}

/**

* 获得信息.

*

* @param code 码值

* @return 信息

*/

public static String getMsg(String code) {

if (innerMessageSource == null) {

throw new CarServerException("工具类没有正确配置");

} else {

Locale locale = Locale.SIMPLIFIED_CHINESE;

return innerMessageSource.getMessage(code, null, locale);

}

}

/**

* 获得信息.

*

* @param code 码值

* @param args 参数

* @return 信息

*/

public static String getMsg(String code, Object... args) {

if (innerMessageSource == null) {

throw new CarServerException("工具类没有正确配置");

} else {

Locale locale = Locale.SIMPLIFIED_CHINESE;

return innerMessageSource.getMessage(code, args, locale);

}

}

}

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
优化这段代码: //获取慢病信息 List<SlowDiseasePatInfo> slowDiseasePattInfosList = new ArrayList<>(); slowDiseasePattInfosList.add(new SlowDiseasePatInfo(slowDiseaseId,"普通慢病报卡")); Result result = detail(slowDiseasePattInfosList); if (null == result.getData()){ return ResultGenerator.genFailedResult("未查到需要上报的数据"); } List<SlowDiseasePatientInfo> list = (List<SlowDiseasePatientInfo>)result.getData(); String outpatNum = list.get(0).getOutpatNum().isEmpty() ? list.get(0).getInpatNum() : list.get(0).getOutpatNum(); //获取患者的院区 String hospitalCode = emrSlowDiseaseDao.getHospitalCode(outpatNum); String unitCode = ConstantEnum.GW_CZ.getValue().equals(hospitalCode) ? ConstantEnum.GW_CZDWBM.getValue() : ConstantEnum.GW_YHDWBM.getValue(); String regCode = ConstantEnum.GW_CZ.getValue().equals(hospitalCode) ? ConstantEnum.GW_CZZCM.getValue() : ConstantEnum.GW_YHZCM.getValue(); Map<String,Object> reqMap = new HashMap<>(); reqMap.put("slowInfo",list.get(0)); reqMap.put("unitCode",unitCode); reqMap.put("regCode",regCode); String reqInfo = MessageUtil.select(reqMap, "/velocity/slowdisease.vm"); Document document = DocumentHelper.parseText(StringEscapeUtils.unescapeJava(reqInfo.replace("xmlns=\"urn:hl7-org:v3\"", ""))); reqInfo = XmlUtils.documentToStr(document); logger.info("请求慢病接口开始{}", reqInfo); String res = HttpClientUtil.sendWebServiceForLis(webservice + "SlowSfqUploadService/SlowSfqUploadService?WSDL", reqInfo.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>","")); logger.info("请求慢病接口结束{}", res); return ResultGenerator.genOkResult(res);
06-08

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值