aop
parent
fdec1b9eda
commit
9420b2fc97
@ -1,25 +0,0 @@
|
|||||||
package com.docus.server.collect;
|
|
||||||
|
|
||||||
import com.docus.server.ws.IWsResult;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class WsResultImpl implements IWsResult {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String ok(Map<String, Object> params) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String fail(String message) {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String ok(String message) {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +1,17 @@
|
|||||||
package com.docus.server.collect.basic.http;
|
package com.docus.server.collect.basic.http;
|
||||||
|
|
||||||
import com.docus.server.collect.service.IHttpTBasicCollectService;
|
import com.docus.server.collect.service.IHttpCollector;
|
||||||
import com.docus.server.record.pojo.dto.TBasicDTO;
|
import com.docus.server.record.pojo.dto.TBasicDTO;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Component("httpTBasicCollectorImpl")
|
||||||
public class HttpTBasicCollectServiceImpl implements IHttpTBasicCollectService {
|
public class HttpTBasicCollectorImpl implements IHttpCollector<TBasicDTO> {
|
||||||
@Override
|
@Override
|
||||||
public List<TBasicDTO> getTBasics(Date startDate, Date endDate, long pageNum, long pageSize) {
|
public List<TBasicDTO> get(Date startDate, Date endDate, long pageNum, long pageSize) {
|
||||||
TBasicDTO deptDTO = new TBasicDTO();
|
TBasicDTO deptDTO = new TBasicDTO();
|
||||||
|
|
||||||
TBasicDTO deptDTO1 = new TBasicDTO();
|
TBasicDTO deptDTO1 = new TBasicDTO();
|
@ -1,17 +1,18 @@
|
|||||||
package com.docus.server.collect.dept.http;
|
package com.docus.server.collect.dept.http;
|
||||||
|
|
||||||
import com.docus.server.collect.service.IHttpDeptCollectService;
|
import com.docus.server.collect.service.IHttpCollector;
|
||||||
import com.docus.server.sys.common.pojo.dto.DeptDTO;
|
import com.docus.server.sys.common.pojo.dto.DeptDTO;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Component("httpDeptCollectorImpl")
|
||||||
public class HttpDeptCollectServiceImpl implements IHttpDeptCollectService {
|
public class HttpDeptCollectorImpl implements IHttpCollector<DeptDTO> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DeptDTO> getDepts(Date startDate, Date endDate, long pageNum, long pageSize) {
|
public List<DeptDTO> get(Date startDate, Date endDate, long pageNum, long pageSize) {
|
||||||
DeptDTO deptDTO = new DeptDTO();
|
DeptDTO deptDTO = new DeptDTO();
|
||||||
deptDTO.setAuthorId("1");
|
deptDTO.setAuthorId("1");
|
||||||
deptDTO.setAuthorName("admin");
|
deptDTO.setAuthorName("admin");
|
@ -1,17 +1,17 @@
|
|||||||
package com.docus.server.collect.user.http;
|
package com.docus.server.collect.user.http;
|
||||||
|
|
||||||
import com.docus.server.collect.service.IHttpUserCollectService;
|
import com.docus.server.collect.service.IHttpCollector;
|
||||||
import com.docus.server.sys.common.pojo.dto.UserDTO;
|
import com.docus.server.sys.common.pojo.dto.UserDTO;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Component("httpUserCollectorImpl")
|
||||||
public class HttpUserCollectServiceImpl implements IHttpUserCollectService {
|
public class HttpUserCollectorImpl implements IHttpCollector<UserDTO> {
|
||||||
@Override
|
@Override
|
||||||
public List<UserDTO> getUsers(Date startDate, Date endDate, long pageNum, long pageSize) {
|
public List<UserDTO> get(Date startDate, Date endDate, long pageNum, long pageSize) {
|
||||||
UserDTO deptDTO = new UserDTO();
|
UserDTO deptDTO = new UserDTO();
|
||||||
deptDTO.setAuthorId("1");
|
deptDTO.setAuthorId("1");
|
||||||
deptDTO.setAuthorName("admin");
|
deptDTO.setAuthorName("admin");
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.docus.server.collect.service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IHttpCollector<T> {
|
||||||
|
/**
|
||||||
|
* 根据配置获取多态的收集器
|
||||||
|
*/
|
||||||
|
List<T> get(Date startDate, Date endDate, long pageNum, long pageSize);
|
||||||
|
}
|
@ -1,10 +0,0 @@
|
|||||||
package com.docus.server.collect.service;
|
|
||||||
|
|
||||||
import com.docus.server.sys.common.pojo.dto.DeptDTO;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface IHttpDeptCollectService {
|
|
||||||
List<DeptDTO> getDepts(Date startDate, Date endDate, long pageNum, long pageSize);
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
package com.docus.server.collect.service;
|
|
||||||
|
|
||||||
import com.docus.server.record.pojo.dto.TBasicDTO;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface IHttpTBasicCollectService {
|
|
||||||
List<TBasicDTO> getTBasics(Date startDate, Date endDate, long pageNum, long pageSize);
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
package com.docus.server.collect.service;
|
|
||||||
|
|
||||||
import com.docus.server.sys.common.pojo.dto.UserDTO;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface IHttpUserCollectService {
|
|
||||||
List<UserDTO> getUsers(Date startDate, Date endDate, long pageNum, long pageSize);
|
|
||||||
}
|
|
@ -0,0 +1,106 @@
|
|||||||
|
package com.docus.server.visitor;
|
||||||
|
|
||||||
|
import com.docus.core.util.Func;
|
||||||
|
import com.docus.core.util.json.JSON;
|
||||||
|
import com.docus.log.context.TrackContext;
|
||||||
|
import com.docus.log.processor.AbstractProcessor;
|
||||||
|
import com.docus.server.collect.infrastructure.dao.CollectTypeEnum;
|
||||||
|
import com.docus.server.collect.infrastructure.dao.StateEnum;
|
||||||
|
import com.docus.server.collect.infrastructure.enums.IIntegerEnum;
|
||||||
|
import com.docus.server.tool.ParamsUtils;
|
||||||
|
import com.docus.server.tool.SpringUtils;
|
||||||
|
import com.docus.server.ws.ITaskOriginalMessageService;
|
||||||
|
import com.docus.server.ws.IWsResult;
|
||||||
|
import com.docus.server.ws.convert.IConverter;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author linruifeng
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class VisitorProcessor extends AbstractProcessor {
|
||||||
|
private IConverter converter;
|
||||||
|
private IWsResult wsResult;
|
||||||
|
private ITaskOriginalMessageService taskOriginalMessageService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object doProcess(TrackContext context) {
|
||||||
|
if (context.isError()) {
|
||||||
|
return afterThrowingProcess(context);
|
||||||
|
} else {
|
||||||
|
return afterReturnProcess(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置通知
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object beforeProcess(TrackContext context) {
|
||||||
|
log.debug("=== AOP 前置通知 ===");
|
||||||
|
String message = (String) context.getArgs()[0];
|
||||||
|
initBeans(context.getBeanNames());
|
||||||
|
Object dto = converter.convert(message, context.getMethodName());
|
||||||
|
String jsonStr = JSON.toJSON(dto);
|
||||||
|
SpringUtils.invokeMethod(context.getClassType(), "setProperty", new Object[]{jsonStr});
|
||||||
|
Long taskId = taskOriginalMessageService.insertTaskOriginalMessage(jsonStr, message,
|
||||||
|
IIntegerEnum.fromDisplay(CollectTypeEnum.class, context.getGroup()));
|
||||||
|
return ParamsUtils.addParam("taskId", taskId).addParam("jsonStr", jsonStr).param();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后置通知
|
||||||
|
*/
|
||||||
|
public Object afterReturnProcess(TrackContext context) {
|
||||||
|
log.debug("=== AOP 后置通知 ===");
|
||||||
|
Map beforeResult = (Map) context.getBeforeResult();
|
||||||
|
Long taskId = (Long) beforeResult.get("taskId");
|
||||||
|
String afterReturnResult = (String) beforeResult.get("jsonStr");
|
||||||
|
if (Func.isNotEmpty(taskId)) {
|
||||||
|
taskOriginalMessageService.updateTaskOriginalMessage(taskId, afterReturnResult, StateEnum.OK);
|
||||||
|
}
|
||||||
|
Map map = JSON.fromJSON(afterReturnResult, Map.class);
|
||||||
|
map.put("msg", "操作成功!");
|
||||||
|
return wsResult.ok(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异常通知
|
||||||
|
*/
|
||||||
|
public Object afterThrowingProcess(TrackContext context) {
|
||||||
|
log.error("=== AOP 异常通知 ===");
|
||||||
|
Map<String, Object> params = ParamsUtils.addParam("msg", context.getExMessageResult()).param();
|
||||||
|
try {
|
||||||
|
Map beforeResult = (Map) context.getBeforeResult();
|
||||||
|
Long taskId = (Long) beforeResult.get("taskId");
|
||||||
|
String afterReturnResult = (String) beforeResult.get("jsonStr");
|
||||||
|
|
||||||
|
log.error(context.getExMessageResult());
|
||||||
|
if (Func.isNotEmpty(taskId)) {
|
||||||
|
taskOriginalMessageService.updateTaskOriginalMessage(taskId, afterReturnResult, StateEnum.FAIL);
|
||||||
|
}
|
||||||
|
params.putAll(JSON.fromJSON(afterReturnResult, Map.class));
|
||||||
|
return wsResult.fail(params);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return wsResult.fail(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后通知
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object afterProcess(TrackContext context) {
|
||||||
|
log.debug("=== AOP 最后通知 ===");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initBeans(String[] beanNames) {
|
||||||
|
this.converter = (IConverter) SpringUtils.getBean(beanNames[0]);
|
||||||
|
this.wsResult = (IWsResult) SpringUtils.getBean(beanNames[1]);
|
||||||
|
this.taskOriginalMessageService = SpringUtils.getBean(ITaskOriginalMessageService.class);
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,11 @@
|
|||||||
package com.docus.server.ws;
|
package com.docus.server.ws;
|
||||||
|
|
||||||
import com.docus.server.collect.infrastructure.dao.CollectTypeEnum;
|
import com.docus.server.collect.infrastructure.dao.CollectTypeEnum;
|
||||||
|
import com.docus.server.collect.infrastructure.dao.StateEnum;
|
||||||
|
|
||||||
public interface ITaskOriginalMessageService {
|
public interface ITaskOriginalMessageService {
|
||||||
|
|
||||||
long insertTaskOriginalMessage(String xml, CollectTypeEnum collectType);
|
Long insertTaskOriginalMessage(Object json, String xml, CollectTypeEnum collectType);
|
||||||
|
|
||||||
void updateTaskOriginalMessage(long id);
|
|
||||||
|
|
||||||
|
void updateTaskOriginalMessage(Long id, Object json, StateEnum stateEnum);
|
||||||
}
|
}
|
||||||
|
@ -1,52 +1,45 @@
|
|||||||
package com.docus.server.ws;
|
package com.docus.server.ws;
|
||||||
|
|
||||||
import com.docus.server.collect.service.CollectService;
|
|
||||||
import com.docus.server.collect.service.IParseService;
|
|
||||||
import com.docus.server.record.pojo.entity.MedicalRecord;
|
|
||||||
import com.docus.server.record.service.IMedicalRecordService;
|
|
||||||
import com.docus.server.sys.common.pojo.dto.DeptDTO;
|
|
||||||
import com.docus.server.sys.service.IPowerDeptService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class WsCollect {
|
public class WsCollect {
|
||||||
@Autowired
|
// @Autowired
|
||||||
private IMedicalRecordService medicalRecordService;
|
// private IMedicalRecordService medicalRecordService;
|
||||||
@Autowired
|
// @Autowired
|
||||||
private IParseService parseService;
|
// private IParseService parseService;
|
||||||
@Autowired
|
// @Autowired
|
||||||
private CollectService collectService;
|
// private CollectService collectService;
|
||||||
@Autowired
|
// @Autowired
|
||||||
private IWsResult wsResult;
|
// private IWsResult wsResult;
|
||||||
@Autowired
|
// @Autowired
|
||||||
private IPowerDeptService powerDeptService;
|
// private IPowerDeptService powerDeptService;
|
||||||
|
//
|
||||||
//接收xml。并且下载病案。
|
// //接收xml。并且下载病案。
|
||||||
public String receiveHandNumbness(String handNumbness) {
|
// public String receiveHandNumbness(String handNumbness) {
|
||||||
log.info("收到手麻消息:{}", handNumbness);
|
// log.info("收到手麻消息:{}", handNumbness);
|
||||||
try {
|
// try {
|
||||||
MedicalRecord medicalRecord = parseService.parseHandNumbness(handNumbness);
|
// MedicalRecord medicalRecord = parseService.parseHandNumbness(handNumbness);
|
||||||
medicalRecordService.receive(medicalRecord);
|
// medicalRecordService.receive(medicalRecord);
|
||||||
return wsResult.ok(medicalRecord.getParams());
|
// return wsResult.ok(medicalRecord.getParams());
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
return wsResult.fail(e.getMessage());
|
// return wsResult.fail(e.getMessage());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public String receiveDept(String deptXml) {
|
// public String receiveDept(String deptXml) {
|
||||||
log.info("收到科室消息:{}", deptXml);
|
// log.info("收到科室消息:{}", deptXml);
|
||||||
try {
|
// try {
|
||||||
DeptDTO dept = parseService.parseDeptXml(deptXml);
|
// DeptDTO dept = parseService.parseDeptXml(deptXml);
|
||||||
|
//
|
||||||
//此处需要存储原xml内容。
|
// //此处需要存储原xml内容。
|
||||||
collectService.receiveDept(dept);
|
// collectService.receiveDept(dept);
|
||||||
return wsResult.ok(dept.getParams());
|
// return wsResult.ok(dept.getParams());
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
return wsResult.fail(e.getMessage(), dept.getParams());
|
// return wsResult.fail(e.getMessage(), dept.getParams());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package com.docus.server.ws.convert;
|
package com.docus.server.ws.convert;
|
||||||
|
|
||||||
import com.docus.server.collect.infrastructure.dao.FlagEnum;
|
|
||||||
|
|
||||||
public interface IConverter<T> {
|
public interface IConverter<T> {
|
||||||
|
|
||||||
T convert(String message, FlagEnum flagEnum);
|
T convert(String message, String methodName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue