|
|
|
@ -2,15 +2,18 @@ package com.docus.webservice.handler;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.docus.webservice.dto.CollectList;
|
|
|
|
|
import com.docus.webservice.dto.SelectColumn;
|
|
|
|
|
import com.docus.webservice.entity.AfInterfaceCollect;
|
|
|
|
|
import com.docus.webservice.entity.AfInterfaceCollectSub;
|
|
|
|
|
import com.docus.webservice.entity.MrReportError;
|
|
|
|
|
|
|
|
|
|
import com.docus.webservice.entity.TBasic;
|
|
|
|
|
import com.docus.webservice.enums.Codes;
|
|
|
|
|
import com.docus.webservice.mapper.AfInterfaceCollectMapper;
|
|
|
|
|
import com.docus.webservice.service.IMrReportErrorService;
|
|
|
|
|
import com.docus.webservice.service.ITBasicService;
|
|
|
|
|
import com.docus.webservice.utils.JsonUtils;
|
|
|
|
|
import com.docus.webservice.utils.ResultUtils;
|
|
|
|
|
import com.docus.webservice.utils.XmlUtils;
|
|
|
|
|
import com.docus.webservice.utils.*;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
|
@ -18,10 +21,9 @@ import javax.jws.WebService;
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
@WebService
|
|
|
|
|
public class TBasicWebService implements ITBasicWebService {
|
|
|
|
@ -32,6 +34,9 @@ public class TBasicWebService implements ITBasicWebService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMrReportErrorService mrReportErrorService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private AfInterfaceCollectMapper afInterfaceCollectMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取jar包所在位置
|
|
|
|
|
*
|
|
|
|
@ -60,41 +65,12 @@ public class TBasicWebService implements ITBasicWebService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String savaAndSub(String tbasic) {
|
|
|
|
|
XmlUtils xmlUtils;
|
|
|
|
|
public String OUT_HOS_REG(String tbasic) {
|
|
|
|
|
try {
|
|
|
|
|
//解析xml
|
|
|
|
|
xmlUtils = new XmlUtils(new ByteArrayInputStream(tbasic.getBytes("UTF-8")));
|
|
|
|
|
//解析json映射文件
|
|
|
|
|
String json = JsonUtils.readJsonFile(CurrentPath() + Codes.JSON_ADDRESS.getMessage());
|
|
|
|
|
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(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()));
|
|
|
|
|
} catch (RuntimeException e) {
|
|
|
|
|
String message = e.getMessage();
|
|
|
|
|
return ResultUtils.fail(message);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(value)) {
|
|
|
|
|
if (selectColumn.getByNull() == 0) {
|
|
|
|
|
insertLog(tbasic);
|
|
|
|
|
return ResultUtils.fail(selectColumn.getQualityColumn() + " 字段不能为空值");
|
|
|
|
|
} else {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (selectColumn.getTableName().equals("t_basic")) {
|
|
|
|
|
tBasicMap.put(selectColumn.getColumnName(), value);
|
|
|
|
|
}
|
|
|
|
|
if (selectColumn.getTableName().equals("t_basic_sub")) {
|
|
|
|
|
tBasicSubMap.put(selectColumn.getColumnName(), value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
parseXml(tbasic,tBasicMap,tBasicSubMap);
|
|
|
|
|
//处理业务
|
|
|
|
|
TBasic tBasic;
|
|
|
|
|
if (tBasicMap != null && tBasicMap.size() > 0) {
|
|
|
|
@ -102,6 +78,7 @@ public class TBasicWebService implements ITBasicWebService {
|
|
|
|
|
tBasic.setCreateTime(new Date());
|
|
|
|
|
try {
|
|
|
|
|
itBasicService.savaAndSub(tBasic, tBasicSubMap);
|
|
|
|
|
this.saveAndCall(tBasic);
|
|
|
|
|
} catch (RuntimeException e) {
|
|
|
|
|
insertLog(tbasic);
|
|
|
|
|
return ResultUtils.fail(e.getMessage());
|
|
|
|
@ -117,44 +94,57 @@ public class TBasicWebService implements ITBasicWebService {
|
|
|
|
|
return ResultUtils.success().asXML();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String updateAndSub(String tbasic) {
|
|
|
|
|
XmlUtils xmlUtils;
|
|
|
|
|
/**
|
|
|
|
|
* 解析xml
|
|
|
|
|
* @param tbasic
|
|
|
|
|
* @param tBasicMap
|
|
|
|
|
* @param tBasicSubMap
|
|
|
|
|
*/
|
|
|
|
|
private void parseXml(String tbasic, HashMap<String, Object> tBasicMap, HashMap<String, Object> tBasicSubMap) {
|
|
|
|
|
XmlUtils xmlUtils = null;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
//解析xml
|
|
|
|
|
xmlUtils = new XmlUtils(new ByteArrayInputStream(tbasic.getBytes("UTF-8")));
|
|
|
|
|
//解析json映射文件
|
|
|
|
|
String path = CurrentPath() + Codes.JSON_ADDRESS.getMessage();
|
|
|
|
|
String json = JsonUtils.readJsonFile(path);
|
|
|
|
|
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(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()));
|
|
|
|
|
} catch (RuntimeException e) {
|
|
|
|
|
String message = e.getMessage();
|
|
|
|
|
return ResultUtils.fail(message);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(value)) {
|
|
|
|
|
if (selectColumn.getByNull() == 0) {
|
|
|
|
|
insertLog(tbasic);
|
|
|
|
|
return ResultUtils.fail(selectColumn.getQualityColumn() + " 字段不能为空值");
|
|
|
|
|
} else {
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
//解析json映射文件
|
|
|
|
|
String json = JsonUtils.readJsonFile(CurrentPath() + Codes.JSON_ADDRESS.getMessage());
|
|
|
|
|
Map jsonMap = JSON.parseObject(json, Map.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()));
|
|
|
|
|
} catch (RuntimeException e) {
|
|
|
|
|
String message = e.getMessage();
|
|
|
|
|
throw new RuntimeException(message);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(value)) {
|
|
|
|
|
if (selectColumn.getByNull() == 0) {
|
|
|
|
|
insertLog(tbasic);
|
|
|
|
|
throw new RuntimeException(selectColumn.getQualityColumn() + " 字段不能为空值");
|
|
|
|
|
} else {
|
|
|
|
|
if (selectColumn.getTableName().equals("t_basic")) {
|
|
|
|
|
tBasicMap.put(selectColumn.getColumnName(), value);
|
|
|
|
|
}
|
|
|
|
|
if (selectColumn.getTableName().equals("t_basic_sub")) {
|
|
|
|
|
tBasicSubMap.put(selectColumn.getColumnName(), value);
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (selectColumn.getTableName().equals("t_basic")) {
|
|
|
|
|
tBasicMap.put(selectColumn.getColumnName(), value);
|
|
|
|
|
}
|
|
|
|
|
if (selectColumn.getTableName().equals("t_basic_sub")) {
|
|
|
|
|
tBasicSubMap.put(selectColumn.getColumnName(), value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String OUT_HOS_CAN(String tbasic) {
|
|
|
|
|
try {
|
|
|
|
|
HashMap<String, Object> tBasicMap = new HashMap<>();
|
|
|
|
|
HashMap<String, Object> tBasicSubMap = new HashMap<>();
|
|
|
|
|
parseXml(tbasic,tBasicMap,tBasicSubMap);
|
|
|
|
|
//处理业务
|
|
|
|
|
TBasic tBasic;
|
|
|
|
|
if (tBasicMap != null && tBasicMap.size() > 0) {
|
|
|
|
@ -166,8 +156,10 @@ public class TBasicWebService implements ITBasicWebService {
|
|
|
|
|
tBasic.setUpdateTime(new Date());
|
|
|
|
|
try {
|
|
|
|
|
itBasicService.updateAndSub(tBasic, tBasicSubMap);
|
|
|
|
|
this.saveAndCall(tBasic);
|
|
|
|
|
} catch (RuntimeException e) {
|
|
|
|
|
insertLog(tbasic);
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return ResultUtils.fail(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
@ -180,4 +172,54 @@ public class TBasicWebService implements ITBasicWebService {
|
|
|
|
|
}
|
|
|
|
|
return ResultUtils.success().asXML();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void saveAndCall(TBasic tBasic) throws URISyntaxException {
|
|
|
|
|
//解析json映射文件
|
|
|
|
|
String json = JsonUtils.readJsonFile(CurrentPath() + Codes.JSON_COLLECTLIST.getMessage());
|
|
|
|
|
if (StringUtils.isNotBlank(json)) {
|
|
|
|
|
Map jsonMap = JSON.parseObject(json, Map.class);
|
|
|
|
|
//任务数
|
|
|
|
|
Integer task_count= JSON.parseObject(String.valueOf(jsonMap.get(Codes.JSON_TASK_COUNT.getMessage())), Integer.class);
|
|
|
|
|
|
|
|
|
|
List<CollectList> collectLists = JSON.parseArray(String.valueOf(jsonMap.get(Codes.JSON_COLLECTLIST_ROOT.getMessage())), CollectList.class);
|
|
|
|
|
|
|
|
|
|
//添加省中医病案采集
|
|
|
|
|
SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0);
|
|
|
|
|
AfInterfaceCollect afc=new AfInterfaceCollect();
|
|
|
|
|
Long afcId=idWorker.nextId();
|
|
|
|
|
afc.setId(afcId);
|
|
|
|
|
afc.setJzh(tBasic.getJzh());
|
|
|
|
|
afc.setTaskCount(task_count);
|
|
|
|
|
afc.setCreateTime(new Date());
|
|
|
|
|
afInterfaceCollectMapper.addAfInterfaceCollect(afc);
|
|
|
|
|
|
|
|
|
|
//添加省中医病案采集-子任务
|
|
|
|
|
List<AfInterfaceCollectSub> list=new ArrayList<>();
|
|
|
|
|
for (CollectList collectList : collectLists) {
|
|
|
|
|
AfInterfaceCollectSub afInterfaceCollectSub = new AfInterfaceCollectSub();
|
|
|
|
|
Long afcsId= idWorker.nextId();
|
|
|
|
|
afInterfaceCollectSub.setId(afcsId);
|
|
|
|
|
afInterfaceCollectSub.setAfInterfaceCollectId(afcId);
|
|
|
|
|
afInterfaceCollectSub.setCollectsysCode(collectList.getCollectsys_code());
|
|
|
|
|
afInterfaceCollectSub.setJzh(tBasic.getJzh());
|
|
|
|
|
collectList.setId(afcsId);
|
|
|
|
|
list.add(afInterfaceCollectSub);
|
|
|
|
|
}
|
|
|
|
|
afInterfaceCollectMapper.addAfInterfaceCollectSub(list);
|
|
|
|
|
|
|
|
|
|
for (CollectList collectList : collectLists) {
|
|
|
|
|
//调用http发送请求
|
|
|
|
|
this.sendHttp(collectList,tBasic.getJzh());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String sendHttp(CollectList collectList,String jzh) throws URISyntaxException {
|
|
|
|
|
Map<String, String > params= new HashMap<>();
|
|
|
|
|
params.put("empId",jzh);
|
|
|
|
|
params.put("collectSubId",String.valueOf(collectList.getId()));
|
|
|
|
|
return HttpUtils.get(collectList.getRequestUrl(),params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|