|
@@ -1,13 +1,16 @@
|
|
|
package com.diagbot.facade.data;
|
|
|
|
|
|
+import com.alibaba.druid.support.json.JSONUtils;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.diagbot.dto.RespDTO;
|
|
|
import com.diagbot.dto.data.ABasDeptInfoDTO;
|
|
|
import com.diagbot.entity.BasDeptInfo;
|
|
|
+import com.diagbot.entity.MedAbnormalInfo;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
import com.diagbot.service.impl.BasDeptInfoServiceImpl;
|
|
|
-import com.diagbot.util.TZDBConn;
|
|
|
+import com.diagbot.util.*;
|
|
|
import com.diagbot.vo.data.ABasDeptInfoVO;
|
|
|
-import com.diagbot.util.BeanUtil;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
@@ -23,6 +26,9 @@ public class ABasDeptInfoFacade extends BasDeptInfoServiceImpl{
|
|
|
@Qualifier("basDeptInfoServiceImpl")
|
|
|
private BasDeptInfoServiceImpl basDeptInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AMedAbnormalInfoFacade aMedAbnormalInfoFacade;
|
|
|
+
|
|
|
private TZDBConn tzDBConn = new TZDBConn();
|
|
|
|
|
|
/**
|
|
@@ -49,53 +55,75 @@ public class ABasDeptInfoFacade extends BasDeptInfoServiceImpl{
|
|
|
* @return
|
|
|
*/
|
|
|
public RespDTO<List<ABasDeptInfoDTO>> executeDept(List<ABasDeptInfoVO> list) {
|
|
|
- if(list!=null && list.size()>0){
|
|
|
- List<BasDeptInfo> basDeptInfoList=Lists.newArrayList();
|
|
|
- List<ABasDeptInfoDTO> basDeptInfoDtoList=Lists.newArrayList();
|
|
|
- basDeptInfoList=BeanUtil.listCopyTo(list,BasDeptInfo.class);
|
|
|
- basDeptInfoDtoList=BeanUtil.listCopyTo(list,ABasDeptInfoDTO.class);
|
|
|
+ try {
|
|
|
+ if(list!=null && list.size()>0){
|
|
|
+ List<BasDeptInfo> basDeptInfoList=Lists.newArrayList();
|
|
|
+ List<ABasDeptInfoDTO> basDeptInfoDtoList=Lists.newArrayList();
|
|
|
+ basDeptInfoList=BeanUtil.listCopyTo(list,BasDeptInfo.class);
|
|
|
+ basDeptInfoDtoList=BeanUtil.listCopyTo(list,ABasDeptInfoDTO.class);
|
|
|
|
|
|
- //循环验证数据有效性
|
|
|
- for (BasDeptInfo basDeptInfo:basDeptInfoList) {
|
|
|
- if("".equals(basDeptInfo.getDeptId())) {
|
|
|
- return RespDTO.onError("请输入科室编码!");
|
|
|
- }else if(basDeptInfo.getHospitalId()==null){
|
|
|
- return RespDTO.onError("请输入医院编码!");
|
|
|
- }else if("".equals(basDeptInfo.getDeptName())){
|
|
|
- return RespDTO.onError("请输入科室名称!");
|
|
|
+ //循环验证数据有效性
|
|
|
+ for (BasDeptInfo basDeptInfo:basDeptInfoList) {
|
|
|
+ if("".equals(basDeptInfo.getDeptId())) {
|
|
|
+ return RespDTO.onError("请输入科室编码!");
|
|
|
+ }else if(basDeptInfo.getHospitalId()==null){
|
|
|
+ return RespDTO.onError("请输入医院编码!");
|
|
|
+ }else if("".equals(basDeptInfo.getDeptName())){
|
|
|
+ return RespDTO.onError("请输入科室名称!");
|
|
|
+ }
|
|
|
}
|
|
|
+ execute(basDeptInfoList);
|
|
|
+ return RespDTO.onSuc(basDeptInfoDtoList);
|
|
|
+ }else {
|
|
|
+ saveAbnormalInfo(JSON.toJSONString(list),"","未接收到数据!");
|
|
|
+ return RespDTO.onError("未接收到数据!");
|
|
|
}
|
|
|
- execute(basDeptInfoList);
|
|
|
- return RespDTO.onSuc(basDeptInfoDtoList);
|
|
|
- }else {
|
|
|
- return RespDTO.onError("未接收到数据!");
|
|
|
+ }catch (Exception e){
|
|
|
+ saveAbnormalInfo(JSON.toJSONString(list),"",e.getMessage());
|
|
|
+ return RespDTO.onError(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void execute(List<BasDeptInfo> basDeptInfoList){
|
|
|
- long startTime=System.currentTimeMillis();
|
|
|
- List<BasDeptInfo> addE=Lists.newArrayList();
|
|
|
- List<BasDeptInfo> updateE=Lists.newArrayList();
|
|
|
- basDeptInfoList.stream().forEach(s -> {
|
|
|
- BasDeptInfo basDeptInfo =this.getOne(new QueryWrapper<BasDeptInfo>()
|
|
|
- .eq("dept_id", s.getDeptId())
|
|
|
- .eq("hospital_id", s.getHospitalId()));
|
|
|
- if (basDeptInfo != null) {
|
|
|
- s.setGmtModified(new Date());
|
|
|
- updateE.add(s);
|
|
|
- } else {
|
|
|
- s.setGmtCreate(new Date());
|
|
|
- addE.add(s);
|
|
|
+ try {
|
|
|
+ List<BasDeptInfo> addE=Lists.newArrayList();
|
|
|
+ List<BasDeptInfo> updateE=Lists.newArrayList();
|
|
|
+ basDeptInfoList.stream().forEach(s -> {
|
|
|
+ BasDeptInfo basDeptInfo =this.getOne(new QueryWrapper<BasDeptInfo>()
|
|
|
+ .eq("dept_id", s.getDeptId())
|
|
|
+ .eq("hospital_id", s.getHospitalId())
|
|
|
+ .eq("is_deleted",IsDeleteEnum.N));
|
|
|
+ if (basDeptInfo != null) {
|
|
|
+ s.setGmtModified(new Date());
|
|
|
+ updateE.add(s);
|
|
|
+ } else {
|
|
|
+ s.setGmtCreate(new Date());
|
|
|
+ addE.add(s);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if(updateE.size()>0){
|
|
|
+ basDeptInfoService.updateBatchByKey(updateE);
|
|
|
}
|
|
|
- });
|
|
|
- if(updateE.size()>0){
|
|
|
- basDeptInfoService.updateBatchByKey(updateE);
|
|
|
- }
|
|
|
- if(addE.size()>0){
|
|
|
- basDeptInfoService.saveBatch(addE);
|
|
|
+ if(addE.size()>0){
|
|
|
+ basDeptInfoService.saveBatch(addE);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ saveAbnormalInfo(JSON.toJSONString(basDeptInfoList),"",e.getMessage());
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- long endTime=System.currentTimeMillis();
|
|
|
- System.out.println("程序运行时间: "+(endTime - startTime)+"ms");
|
|
|
+ /**
|
|
|
+ * 接口日志记录
|
|
|
+ * @param paramIn
|
|
|
+ * @param paramOut
|
|
|
+ * @param remark
|
|
|
+ */
|
|
|
+ private void saveAbnormalInfo(String paramIn,String paramOut,String remark){
|
|
|
+ MedAbnormalInfo medAbnormalInfo=new MedAbnormalInfo();
|
|
|
+ medAbnormalInfo.setParamIn(paramIn);
|
|
|
+ medAbnormalInfo.setParamOut(paramOut);
|
|
|
+ medAbnormalInfo.setRamark(remark);
|
|
|
+ medAbnormalInfo.setGmtCreate(new Date());
|
|
|
+ aMedAbnormalInfoFacade.save(medAbnormalInfo);
|
|
|
}
|
|
|
}
|