web service 住院患者信息接口完成

docus_webservice_1.1
lzy 4 years ago
parent 2ffa29525b
commit 7d3c7c5c72

@ -12,7 +12,7 @@ target/
.settings
.springBeans
.sts4-cache
*/mvn
### IntelliJ IDEA ###
.idea
*.iws

@ -26,7 +26,7 @@
"tableName": "t_basic",
"columnName": "emp_id",
"qualityColumn": "EMPI_ID",
"byNull":0
"byNull":1
},
{
"serialNumber": "5",

@ -4,14 +4,29 @@ package com.docus.webservice.enums;
*
*/
public enum Codes {
//接口成功
SUCCESS("0", "成功"),
//接口失败
ERROR("1", "失败"),
//web service返回根节点
RESPONSE("100","Response"),
//web service返回二级节点
RET_INFO("101","RetInfo"),
//web service 返回代码
RET_CODE("102","RetCode"),
//web service返回描述部分
RET_CON("103","RetCon"),
EXTERNAL("9999","201_P_WS_JYBGTS"),
JSON_ADDRESS("999",System.getProperty("user.dir")+"\\docus-webservice\\dataConfig\\homeQualitySet.json");
//web service 服务名
EXTERNAL("9999","docus_tBasic_data"),
//静态文件存放位置
JSON_ADDRESS("999",System.getProperty("user.dir")+"\\docus-webservice\\dataConfig\\homeQualitySet.json"),
//接收二级节点
MSG("201","Msg"),
//接收三级节点
// PAT_INFO("202","PatInfo"),
//静态文件根元素名
SELECT_COLUMNS("10000","selectColumns")
;
//代码
private String code;
//描述

@ -7,7 +7,7 @@ import javax.jws.WebService;
public interface ITBasicWebService {
/**
*
*
* @param tbasic
* @return
*/

@ -2,6 +2,7 @@ package com.docus.webservice.handler;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.docus.webservice.dto.SelectColumn;
import com.docus.webservice.enums.Codes;
import com.docus.webservice.entity.TBasic;
@ -12,10 +13,7 @@ import com.docus.webservice.utils.JsonUtils;
import com.docus.webservice.utils.ResultUtils;
import com.docus.webservice.utils.XmlUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import javax.jws.WebService;
import java.io.ByteArrayInputStream;
import java.util.HashMap;
@ -34,7 +32,7 @@ public class TBasicWebService implements ITBasicWebService {
@Override
public String savaAndSub(String tbasic) {
XmlUtils xmlUtils = null;
XmlUtils xmlUtils;
try {
//解析xml
xmlUtils = new XmlUtils(new ByteArrayInputStream(tbasic.getBytes("UTF-8")));
@ -43,14 +41,13 @@ public class TBasicWebService implements ITBasicWebService {
Map jsonMap = JSON.parseObject(json, Map.class);
HashMap<String, Object> tBasicMap = new HashMap<>();
HashMap<String, Object> tBasicSubMap = new HashMap<>();
List<SelectColumn> selectColumns = JSON.parseArray(String.valueOf(jsonMap.get("selectColumns")), SelectColumn.class);
List<SelectColumn> selectColumns = JSON.parseArray(String.valueOf(jsonMap.get(Codes.SELECT_COLUMNS.getMessage())), SelectColumn.class);
String value;
for (SelectColumn selectColumn : selectColumns) {
try {
value = xmlUtils.getElementText(selectColumn.getQualityColumn())==null?null:String.valueOf(xmlUtils.getElementText(selectColumn.getQualityColumn()));
value = xmlUtils.getElementText(selectColumn.getQualityColumn()) == null ? null : String.valueOf(xmlUtils.getElementText(selectColumn.getQualityColumn()));
} catch (RuntimeException e) {
String message = e.getMessage();
System.out.println(message);
return ResultUtils.fail(message);
}
if (StringUtils.isBlank(value)) {
@ -74,7 +71,8 @@ public class TBasicWebService implements ITBasicWebService {
int insert;
if (tBasicMap != null && tBasicMap.size() > 0) {
tBasic = JSON.parseObject(JSON.toJSONString(tBasicMap), TBasic.class);
if (StringUtils.isBlank(tBasic.getPatientId())) {
TBasic selectTBasic = tBasicMapper.selectOne(new QueryWrapper<TBasic>().eq("emp_id", tBasic.getEmpId()));
if (selectTBasic == null) {
//新增
insert = tBasicMapper.insert(tBasic);
if (insert <= 0) {
@ -88,15 +86,18 @@ public class TBasicWebService implements ITBasicWebService {
}
} else {
//修改
insert=tBasicMapper.updateById(tBasic);
insert = tBasicMapper.update(tBasic, new QueryWrapper<TBasic>().eq("emp_id", tBasic.getEmpId()));
if (insert <= 0) {
return ResultUtils.fail("数据库执行出错,请重试");
}
tBasicSub = JSON.parseObject(JSON.toJSONString(tBasicSubMap), TBasicSub.class);
tBasicSub.setPatientId(tBasic.getPatientId());
insert = tBasicSubMapper.updateById(tBasicSub);
if (insert <= 0) {
return ResultUtils.fail("数据库执行出错,请重试");
if (tBasicSubMap != null && tBasicSubMap.size() > 0) {
tBasicSub = JSON.parseObject(JSON.toJSONString(tBasicSubMap), TBasicSub.class);
tBasicSub.setPatientId(selectTBasic.getPatientId());
insert = tBasicSubMapper.updateById(tBasicSub);
if (insert <= 0) {
return ResultUtils.fail("数据库执行出错,请重试");
}
}
}
}

@ -1,5 +1,6 @@
package com.docus.webservice.utils;
import com.docus.webservice.enums.Codes;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
@ -46,15 +47,15 @@ public class XmlUtils {
//定位根节点
Element root = document.getRootElement();
//根据名称定位节点
Element msg = root.element("Msg");
Element msg = root.element(Codes.MSG.getMessage());
if(msg==null){
throw new RuntimeException("没有Msg节点");
throw new RuntimeException("没有"+Codes.MSG.getMessage()+"节点");
}
Element patInfo = msg.element("PatInfo");
if(patInfo==null){
throw new RuntimeException("没有PatInfo节点");
}
Element element = patInfo.element(name);
// Element patInfo = msg.element(Codes.PAT_INFO.getMessage());
// if(patInfo==null){
// throw new RuntimeException("没有"+Codes.PAT_INFO.getMessage()+"节点");
// }
Element element = msg.element(name);
if(element==null){
return null;
}

Loading…
Cancel
Save