|
|
|
@ -2,22 +2,25 @@ 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.MrReportError;
|
|
|
|
|
import com.docus.webservice.entity.TBasic;
|
|
|
|
|
import com.docus.webservice.entity.TBasicSub;
|
|
|
|
|
import com.docus.webservice.mapper.TBasicMapper;
|
|
|
|
|
import com.docus.webservice.mapper.TBasicSubMapper;
|
|
|
|
|
import com.docus.webservice.enums.Codes;
|
|
|
|
|
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 org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
@ -26,14 +29,19 @@ import java.util.Map;
|
|
|
|
|
public class TBasicWebService implements ITBasicWebService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private TBasicMapper tBasicMapper;
|
|
|
|
|
private ITBasicService itBasicService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private TBasicSubMapper tBasicSubMapper;
|
|
|
|
|
private IMrReportErrorService mrReportErrorService;
|
|
|
|
|
|
|
|
|
|
private String CurrentPath(){
|
|
|
|
|
/**
|
|
|
|
|
* 获取jar包所在位置
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private String CurrentPath() {
|
|
|
|
|
File dir = new File(".");
|
|
|
|
|
String currentpath ="";
|
|
|
|
|
String currentpath = "";
|
|
|
|
|
try {
|
|
|
|
|
currentpath = dir.getCanonicalPath();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
@ -42,6 +50,17 @@ public class TBasicWebService implements ITBasicWebService {
|
|
|
|
|
return currentpath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 记录日志
|
|
|
|
|
*/
|
|
|
|
|
private void insertLog(String xml) {
|
|
|
|
|
MrReportError mrReportError = new MrReportError();
|
|
|
|
|
mrReportError.setCreateTime(new Date());
|
|
|
|
|
mrReportError.setReportType(Integer.parseInt(Codes.ERROR_CODE.getMessage()));
|
|
|
|
|
mrReportError.setXml(xml);
|
|
|
|
|
mrReportErrorService.save(mrReportError);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String savaAndSub(String tbasic) {
|
|
|
|
|
XmlUtils xmlUtils;
|
|
|
|
@ -49,7 +68,7 @@ public class TBasicWebService implements ITBasicWebService {
|
|
|
|
|
//解析xml
|
|
|
|
|
xmlUtils = new XmlUtils(new ByteArrayInputStream(tbasic.getBytes("UTF-8")));
|
|
|
|
|
//解析json映射文件
|
|
|
|
|
String json = JsonUtils.readJsonFile(CurrentPath()+Codes.JSON_ADDRESS.getMessage());
|
|
|
|
|
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<>();
|
|
|
|
@ -64,6 +83,7 @@ public class TBasicWebService implements ITBasicWebService {
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(value)) {
|
|
|
|
|
if (selectColumn.getByNull() == 0) {
|
|
|
|
|
insertLog(tbasic);
|
|
|
|
|
return ResultUtils.fail(selectColumn.getQualityColumn() + " 字段不能为空值");
|
|
|
|
|
} else {
|
|
|
|
|
continue;
|
|
|
|
@ -79,28 +99,18 @@ public class TBasicWebService implements ITBasicWebService {
|
|
|
|
|
}
|
|
|
|
|
//处理业务
|
|
|
|
|
TBasic tBasic;
|
|
|
|
|
TBasicSub tBasicSub;
|
|
|
|
|
int insert;
|
|
|
|
|
if (tBasicMap != null && tBasicMap.size() > 0) {
|
|
|
|
|
tBasic = JSON.parseObject(JSON.toJSONString(tBasicMap), TBasic.class);
|
|
|
|
|
TBasic selectTBasic = tBasicMapper.selectOne(new QueryWrapper<TBasic>().eq("emp_id", tBasic.getEmpId()));
|
|
|
|
|
if (selectTBasic == null) {
|
|
|
|
|
//新增
|
|
|
|
|
insert = tBasicMapper.insert(tBasic);
|
|
|
|
|
if (insert <= 0) {
|
|
|
|
|
return ResultUtils.fail("数据库执行出错,请重试");
|
|
|
|
|
}
|
|
|
|
|
tBasicSub = JSON.parseObject(JSON.toJSONString(tBasicSubMap), TBasicSub.class);
|
|
|
|
|
tBasicSub.setPatientId(tBasic.getPatientId());
|
|
|
|
|
insert = tBasicSubMapper.insert(tBasicSub);
|
|
|
|
|
if (insert <= 0) {
|
|
|
|
|
return ResultUtils.fail("数据库执行出错,请重试");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return ResultUtils.fail("emp_id不能和已有的重复");
|
|
|
|
|
tBasic.setCreateTime(new Date());
|
|
|
|
|
try {
|
|
|
|
|
itBasicService.savaAndSub(tBasic, tBasicSubMap);
|
|
|
|
|
} catch (RuntimeException e) {
|
|
|
|
|
insertLog(tbasic);
|
|
|
|
|
return ResultUtils.fail(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
ResultUtils.fail("请提供完整的xml");
|
|
|
|
|
} else {
|
|
|
|
|
insertLog(tbasic);
|
|
|
|
|
return ResultUtils.fail("请提供完整的xml");
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
@ -116,8 +126,7 @@ public class TBasicWebService implements ITBasicWebService {
|
|
|
|
|
//解析xml
|
|
|
|
|
xmlUtils = new XmlUtils(new ByteArrayInputStream(tbasic.getBytes("UTF-8")));
|
|
|
|
|
//解析json映射文件
|
|
|
|
|
String path=CurrentPath()+Codes.JSON_ADDRESS.getMessage();
|
|
|
|
|
System.out.println(path);
|
|
|
|
|
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<>();
|
|
|
|
@ -133,6 +142,7 @@ public class TBasicWebService implements ITBasicWebService {
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(value)) {
|
|
|
|
|
if (selectColumn.getByNull() == 0) {
|
|
|
|
|
insertLog(tbasic);
|
|
|
|
|
return ResultUtils.fail(selectColumn.getQualityColumn() + " 字段不能为空值");
|
|
|
|
|
} else {
|
|
|
|
|
continue;
|
|
|
|
@ -148,38 +158,29 @@ public class TBasicWebService implements ITBasicWebService {
|
|
|
|
|
}
|
|
|
|
|
//处理业务
|
|
|
|
|
TBasic tBasic;
|
|
|
|
|
TBasicSub tBasicSub;
|
|
|
|
|
int insert;
|
|
|
|
|
if (tBasicMap != null && tBasicMap.size() > 0) {
|
|
|
|
|
tBasic = JSON.parseObject(JSON.toJSONString(tBasicMap), TBasic.class);
|
|
|
|
|
if(StringUtils.isBlank(tBasic.getEmpId())){
|
|
|
|
|
if (StringUtils.isBlank(tBasic.getEmpId())) {
|
|
|
|
|
insertLog(tbasic);
|
|
|
|
|
return ResultUtils.fail("emp_id字段不能为空值");
|
|
|
|
|
}
|
|
|
|
|
TBasic selectTBasic = tBasicMapper.selectOne(new QueryWrapper<TBasic>().eq("emp_id", tBasic.getEmpId()));
|
|
|
|
|
if(selectTBasic!=null){
|
|
|
|
|
insert = tBasicMapper.update(tBasic, new QueryWrapper<TBasic>().eq("emp_id", tBasic.getEmpId()));
|
|
|
|
|
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("数据库执行出错,请重试");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
ResultUtils.fail("修改时,需提供有效的emp_id");
|
|
|
|
|
tBasic.setUpdateTime(new Date());
|
|
|
|
|
try {
|
|
|
|
|
itBasicService.updateAndSub(tBasic, tBasicSubMap);
|
|
|
|
|
} catch (RuntimeException e) {
|
|
|
|
|
insertLog(tbasic);
|
|
|
|
|
return ResultUtils.fail(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
ResultUtils.fail("请提供完整的xml");
|
|
|
|
|
} else {
|
|
|
|
|
insertLog(tbasic);
|
|
|
|
|
return ResultUtils.fail("请提供完整的xml");
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return ResultUtils.fail();
|
|
|
|
|
}
|
|
|
|
|
return ResultUtils.success().asXML();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|