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

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

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

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

@ -4,14 +4,29 @@ package com.docus.webservice.enums;
* *
*/ */
public enum Codes { public enum Codes {
//接口成功
SUCCESS("0", "成功"), SUCCESS("0", "成功"),
//接口失败
ERROR("1", "失败"), ERROR("1", "失败"),
//web service返回根节点
RESPONSE("100","Response"), RESPONSE("100","Response"),
//web service返回二级节点
RET_INFO("101","RetInfo"), RET_INFO("101","RetInfo"),
//web service 返回代码
RET_CODE("102","RetCode"), RET_CODE("102","RetCode"),
//web service返回描述部分
RET_CON("103","RetCon"), RET_CON("103","RetCon"),
EXTERNAL("9999","201_P_WS_JYBGTS"), //web service 服务名
JSON_ADDRESS("999",System.getProperty("user.dir")+"\\docus-webservice\\dataConfig\\homeQualitySet.json"); 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; private String code;
//描述 //描述

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

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

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

Loading…
Cancel
Save