Browse Source

增加日志功能

lantone 5 years ago
parent
commit
0cca5a11fd

+ 3 - 18
src/main/java/com/diagbot/facade/data/ABasDeptInfoFacade.java

@@ -75,11 +75,11 @@ public class ABasDeptInfoFacade extends BasDeptInfoServiceImpl{
                 execute(basDeptInfoList);
                 return RespDTO.onSuc(basDeptInfoDtoList);
             }else {
-                saveAbnormalInfo(JSON.toJSONString(list),"","未接收到数据!");
+                aMedAbnormalInfoFacade.saveAbnormalInfo(JSON.toJSONString(list),"","未接收到数据!");
                 return RespDTO.onError("未接收到数据!");
             }
         }catch (Exception e){
-            saveAbnormalInfo(JSON.toJSONString(list),"",e.getMessage());
+            aMedAbnormalInfoFacade.saveAbnormalInfo(JSON.toJSONString(list),"",e.getMessage());
             return RespDTO.onError(e.getMessage());
         }
     }
@@ -108,22 +108,7 @@ public class ABasDeptInfoFacade extends BasDeptInfoServiceImpl{
                 basDeptInfoService.saveBatch(addE);
             }
         }catch (Exception e){
-            saveAbnormalInfo(JSON.toJSONString(basDeptInfoList),"",e.getMessage());
+            aMedAbnormalInfoFacade.saveAbnormalInfo(JSON.toJSONString(basDeptInfoList),"",e.getMessage());
         }
     }
-
-    /**
-     * 接口日志记录
-     * @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);
-    }
 }

+ 47 - 37
src/main/java/com/diagbot/facade/data/ABasDoctorInfoFacade.java

@@ -1,5 +1,6 @@
 package com.diagbot.facade.data;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.data.ABasDoctorInfoDTO;
@@ -22,6 +23,9 @@ public class ABasDoctorInfoFacade extends BasDoctorInfoServiceImpl {
     @Qualifier("basDoctorInfoServiceImpl")
     private BasDoctorInfoServiceImpl basDoctorInfoService;
 
+    @Autowired
+    private AMedAbnormalInfoFacade aMedAbnormalInfoFacade;
+
     private TZDBConn tzDBConn = new TZDBConn();
 
     /**
@@ -47,50 +51,56 @@ public class ABasDoctorInfoFacade extends BasDoctorInfoServiceImpl {
      * @return
      */
     public RespDTO<List<ABasDoctorInfoDTO>> executeDoctor(List<ABasDoctorInfoVO> list) {
-        if(list!=null && list.size()>0){
-            List<BasDoctorInfo> basDoctorInfoList=Lists.newArrayList();
-            List<ABasDoctorInfoDTO> basDoctorDtoList=Lists.newArrayList();
-            basDoctorInfoList=BeanUtil.listCopyTo(list,BasDoctorInfo.class);
-            basDoctorDtoList=BeanUtil.listCopyTo(list,ABasDoctorInfoDTO.class);
-            //循环验证数据有效性
-            for (BasDoctorInfo basDoctorInfo:basDoctorInfoList) {
-                if("".equals(basDoctorInfo.getDoctorId())) {
-                    return RespDTO.onError("请输入医生编码!");
-                }else if(basDoctorInfo.getHospitalId()==null){
-                    return RespDTO.onError("请输入医院编码!");
+        try {
+            if(list!=null && list.size()>0){
+                List<BasDoctorInfo> basDoctorInfoList=Lists.newArrayList();
+                List<ABasDoctorInfoDTO> basDoctorDtoList=Lists.newArrayList();
+                basDoctorInfoList=BeanUtil.listCopyTo(list,BasDoctorInfo.class);
+                basDoctorDtoList=BeanUtil.listCopyTo(list,ABasDoctorInfoDTO.class);
+                //循环验证数据有效性
+                for (BasDoctorInfo basDoctorInfo:basDoctorInfoList) {
+                    if("".equals(basDoctorInfo.getDoctorId())) {
+                        return RespDTO.onError("请输入医生编码!");
+                    }else if(basDoctorInfo.getHospitalId()==null){
+                        return RespDTO.onError("请输入医院编码!");
+                    }
                 }
+                execute(basDoctorInfoList);
+                return RespDTO.onSuc(basDoctorDtoList);
+            }else{
+                aMedAbnormalInfoFacade.saveAbnormalInfo(JSON.toJSONString(list),"","未接收到数据!");
+                return RespDTO.onError("未接收到数据!");
             }
-            execute(basDoctorInfoList);
-            return RespDTO.onSuc(basDoctorDtoList);
-        }else{
-            return RespDTO.onError("未接收到数据!");
+        }catch (Exception e){
+            aMedAbnormalInfoFacade.saveAbnormalInfo(JSON.toJSONString(list),"",e.getMessage());
+            return RespDTO.onError(e.getMessage());
         }
     }
 
     public void execute(List<BasDoctorInfo> basDoctorInfoList){
-        long startTime=System.currentTimeMillis();
-        List<BasDoctorInfo> addE=Lists.newArrayList();
-        List<BasDoctorInfo> updateE=Lists.newArrayList();
-        basDoctorInfoList.stream().forEach(s -> {
-            BasDoctorInfo basDoctorInfo =this.baseMapper.selectOne(new QueryWrapper<BasDoctorInfo>()
-                    .eq("doctor_id", s.getDoctorId())
-                    .eq("hospital_id", s.getHospitalId()));
-            if (basDoctorInfo != null) {
-                s.setGmtModified(new Date());
-                updateE.add(s);
-            } else {
-                s.setGmtCreate(new Date());
-                addE.add(s);
+        try{
+            List<BasDoctorInfo> addE=Lists.newArrayList();
+            List<BasDoctorInfo> updateE=Lists.newArrayList();
+            basDoctorInfoList.stream().forEach(s -> {
+                BasDoctorInfo basDoctorInfo =this.baseMapper.selectOne(new QueryWrapper<BasDoctorInfo>()
+                        .eq("doctor_id", s.getDoctorId())
+                        .eq("hospital_id", s.getHospitalId()));
+                if (basDoctorInfo != null) {
+                    s.setGmtModified(new Date());
+                    updateE.add(s);
+                } else {
+                    s.setGmtCreate(new Date());
+                    addE.add(s);
+                }
+            });
+            if(updateE.size()>0){
+                basDoctorInfoService.updateBatchByKey(updateE);
             }
-        });
-        if(updateE.size()>0){
-            basDoctorInfoService.updateBatchByKey(updateE);
-        }
-        if(addE.size()>0){
-            basDoctorInfoService.saveBatch(addE);
+            if(addE.size()>0){
+                basDoctorInfoService.saveBatch(addE);
+            }
+        }catch (Exception e){
+            aMedAbnormalInfoFacade.saveAbnormalInfo(JSON.toJSONString(basDoctorInfoList),"",e.getMessage());
         }
-
-        long endTime=System.currentTimeMillis();
-        System.out.println("程序运行时间: "+(endTime - startTime)+"ms");
     }
 }

+ 71 - 59
src/main/java/com/diagbot/facade/data/ABehospitalInfoFacade.java

@@ -1,5 +1,6 @@
 package com.diagbot.facade.data;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.data.ABehospitalInfoDTO;
@@ -34,6 +35,9 @@ public class ABehospitalInfoFacade extends BehospitalInfoServiceImpl {
     @Autowired
     private AMedicalRecordFacade aMedicalRecordFacade;
 
+    @Autowired
+    private AMedAbnormalInfoFacade aMedAbnormalInfoFacade;
+
     @Autowired
     private QcAbnormalFacade qcAbnormalFacade;
 
@@ -65,73 +69,81 @@ public class ABehospitalInfoFacade extends BehospitalInfoServiceImpl {
      * @return
      */
     public RespDTO<List<ABehospitalInfoDTO>> executeBehospital(List<ABehospitalInfoVO> list) {
-        if(list!=null && list.size()>0) {
-            List<BehospitalInfo> behospitalInfoList = Lists.newArrayList();
-            List<ABehospitalInfoDTO> behospitalInfoDtoList = Lists.newArrayList();
-            list.stream().forEach(s->{
-                BehospitalInfo behospitalInfo=new BehospitalInfo();
-                BeanUtil.copyProperties(s,behospitalInfo);
-                if(StringUtil.isNotBlank(s.getBirthday())) {
-                    behospitalInfo.setBirthday(DateUtil.parseDate(s.getBirthday()));
-                }
-                if(StringUtil.isNotBlank(s.getLeaveHospitalDate())) {
-                    behospitalInfo.setLeaveHospitalDate(DateUtil.parseDateTime(s.getLeaveHospitalDate()));
-                }
-                if(StringUtil.isNotBlank(s.getBehospitalDate())){
-                    behospitalInfo.setBehospitalDate(DateUtil.parseDateTime(s.getBehospitalDate()));
-                }
-                if(StringUtil.isNotBlank(s.getPlacefileDate())){
-                    behospitalInfo.setPlacefileDate(DateUtil.parseDateTime(s.getPlacefileDate()));
-                }
-                behospitalInfoList.add(behospitalInfo);
-
-            });
-
-            //循环验证数据有效性
-            for (BehospitalInfo behospitalInfo:behospitalInfoList) {
-                if("".equals(behospitalInfo.getBehospitalCode())) {
-                    return RespDTO.onError("请输入病人住院编码!");
-                }else if(behospitalInfo.getHospitalId()==null){
-                    return RespDTO.onError("请输入医院编码!");
-                }else if("".equals(behospitalInfo.getBehDeptId())){
-                    return RespDTO.onError("请输入住院科室编码!");
-                }else if("".equals(behospitalInfo.getBehDeptName())){
-                    return RespDTO.onError("请输入住院科室名称!");
+        try {
+            if(list!=null && list.size()>0) {
+                List<BehospitalInfo> behospitalInfoList = Lists.newArrayList();
+                List<ABehospitalInfoDTO> behospitalInfoDtoList = Lists.newArrayList();
+                list.stream().forEach(s->{
+                    BehospitalInfo behospitalInfo=new BehospitalInfo();
+                    BeanUtil.copyProperties(s,behospitalInfo);
+                    if(StringUtil.isNotBlank(s.getBirthday())) {
+                        behospitalInfo.setBirthday(DateUtil.parseDate(s.getBirthday()));
+                    }
+                    if(StringUtil.isNotBlank(s.getLeaveHospitalDate())) {
+                        behospitalInfo.setLeaveHospitalDate(DateUtil.parseDateTime(s.getLeaveHospitalDate()));
+                    }
+                    if(StringUtil.isNotBlank(s.getBehospitalDate())){
+                        behospitalInfo.setBehospitalDate(DateUtil.parseDateTime(s.getBehospitalDate()));
+                    }
+                    if(StringUtil.isNotBlank(s.getPlacefileDate())){
+                        behospitalInfo.setPlacefileDate(DateUtil.parseDateTime(s.getPlacefileDate()));
+                    }
+                    behospitalInfoList.add(behospitalInfo);
+
+                });
+
+                //循环验证数据有效性
+                for (BehospitalInfo behospitalInfo:behospitalInfoList) {
+                    if("".equals(behospitalInfo.getBehospitalCode())) {
+                        return RespDTO.onError("请输入病人住院编码!");
+                    }else if(behospitalInfo.getHospitalId()==null){
+                        return RespDTO.onError("请输入医院编码!");
+                    }else if("".equals(behospitalInfo.getBehDeptId())){
+                        return RespDTO.onError("请输入住院科室编码!");
+                    }else if("".equals(behospitalInfo.getBehDeptName())){
+                        return RespDTO.onError("请输入住院科室名称!");
+                    }
                 }
+                execute(behospitalInfoList);
+                behospitalInfoDtoList = BeanUtil.listCopyTo(list, ABehospitalInfoDTO.class);
+                return RespDTO.onSuc(behospitalInfoDtoList);
+            }else{
+                aMedAbnormalInfoFacade.saveAbnormalInfo(JSON.toJSONString(list),"","未接收到数据!");
+                return RespDTO.onError("未接收到数据!");
             }
-            execute(behospitalInfoList);
-            behospitalInfoDtoList = BeanUtil.listCopyTo(list, ABehospitalInfoDTO.class);
-            return RespDTO.onSuc(behospitalInfoDtoList);
-        }else{
-            return RespDTO.onError("未接收到数据!");
+        }catch (Exception e){
+            aMedAbnormalInfoFacade.saveAbnormalInfo(JSON.toJSONString(list),"",e.getMessage());
+            return RespDTO.onError(e.getMessage());
         }
     }
 
     public void execute(List<BehospitalInfo> behospitalInfoList){
-        List<BehospitalInfo> addE = Lists.newLinkedList();
-        List<BehospitalInfo> updateE = Lists.newLinkedList();
-        behospitalInfoList.stream().forEach(s -> {
-            BehospitalInfo behospitalInfo = this.getOne(new QueryWrapper<BehospitalInfo>()
-                    .eq("behospital_code", s.getBehospitalCode())
-                    .eq("hospital_id", s.getHospitalId())
-                    .eq("is_deleted",IsDeleteEnum.N), false);
-            if (behospitalInfo != null) {
-                s.setGmtModified(new Date());
-                s.setQcTypeId(initQcTypeId(s));
-                updateE.add(s);
-            } else {
-                s.setGmtCreate(new Date());
-                s.setQcTypeId(initQcTypeId(s));
-                addE.add(s);
+        try{
+            List<BehospitalInfo> addE = Lists.newLinkedList();
+            List<BehospitalInfo> updateE = Lists.newLinkedList();
+            behospitalInfoList.stream().forEach(s -> {
+                BehospitalInfo behospitalInfo = this.getOne(new QueryWrapper<BehospitalInfo>()
+                        .eq("behospital_code", s.getBehospitalCode())
+                        .eq("hospital_id", s.getHospitalId()), false);
+                if (behospitalInfo != null) {
+                    s.setGmtModified(new Date());
+                    s.setQcTypeId(initQcTypeId(s));
+                    updateE.add(s);
+                } else {
+                    s.setGmtCreate(new Date());
+                    s.setQcTypeId(initQcTypeId(s));
+                    addE.add(s);
+                }
+            });
+            if(addE.size()>0){
+                behospitalInfoService.saveBatch(addE);
             }
-        });
-        if(addE.size()>0){
-            behospitalInfoService.saveBatch(addE);
-        }
-        if(updateE.size()>0){
-            behospitalInfoService.updateBatchByKey(updateE);
+            if(updateE.size()>0){
+                behospitalInfoService.updateBatchByKey(updateE);
+            }
+        }catch (Exception e){
+            aMedAbnormalInfoFacade.saveAbnormalInfo(JSON.toJSONString(behospitalInfoList),"",e.getMessage());
         }
-
     }
 
     /**

+ 64 - 50
src/main/java/com/diagbot/facade/data/ADoctorAdviceFacade.java

@@ -1,5 +1,6 @@
 package com.diagbot.facade.data;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.data.ADoctorAdviceDTO;
@@ -25,6 +26,9 @@ public class ADoctorAdviceFacade extends DoctorAdviceServiceImpl{
     @Qualifier("doctorAdviceServiceImpl")
     private DoctorAdviceServiceImpl doctorAdviceService;
 
+    @Autowired
+    private AMedAbnormalInfoFacade aMedAbnormalInfoFacade;
+
     private TZDBConn tzDBConn = new TZDBConn();
 
     /**
@@ -48,62 +52,72 @@ public class ADoctorAdviceFacade extends DoctorAdviceServiceImpl{
      * @return
      */
     public RespDTO<List<ADoctorAdviceDTO>> executeDoctorAdvice(List<ADoctorAdviceVO> list) {
-        if(list!=null && list.size()>0){
-            //循环验证数据有效性
-            for (ADoctorAdviceVO doctorAdvice:list) {
-                if("".equals(doctorAdvice.getDoctorAdviceId())) {
-                    return RespDTO.onError("请输入病人医嘱编码!");
-                }else if(doctorAdvice.getHospitalId()==null){
-                    return RespDTO.onError("请输入医院编码!");
-                }else if("".equals(doctorAdvice.getBehospitalCode())){
-                    return RespDTO.onError("请输入病人住院编码!");
+        try {
+            if(list!=null && list.size()>0){
+                //循环验证数据有效性
+                for (ADoctorAdviceVO doctorAdvice:list) {
+                    if("".equals(doctorAdvice.getDoctorAdviceId())) {
+                        return RespDTO.onError("请输入病人医嘱编码!");
+                    }else if(doctorAdvice.getHospitalId()==null){
+                        return RespDTO.onError("请输入医院编码!");
+                    }else if("".equals(doctorAdvice.getBehospitalCode())){
+                        return RespDTO.onError("请输入病人住院编码!");
+                    }
                 }
+                //初始、格式化数据
+                List<DoctorAdvice> doctorAdviceList=Lists.newArrayList();
+                List<ADoctorAdviceDTO> doctorAdviceDtoList=Lists.newArrayList();
+                list.stream().forEach(s->{
+                    DoctorAdvice doctorAdvice=new DoctorAdvice();
+                    BeanUtil.copyProperties(s,doctorAdvice);
+                    if(StringUtil.isNotBlank(s.getDaStartDate())){
+                        doctorAdvice.setDaStartDate(DateUtil.parseDateTime(s.getDaStartDate()));
+                    }
+                    if(StringUtil.isNotBlank(s.getDaStopDate())){
+                        doctorAdvice.setDaStopDate(DateUtil.parseDateTime(s.getDaStopDate()));
+                    }
+                    doctorAdviceList.add(doctorAdvice);
+                });
+                execute(doctorAdviceList);
+                doctorAdviceDtoList=BeanUtil.listCopyTo(list,ADoctorAdviceDTO.class);
+                return RespDTO.onSuc(doctorAdviceDtoList);
+            }else{
+                aMedAbnormalInfoFacade.saveAbnormalInfo(JSON.toJSONString(list),"","未接收到数据!");
+                return RespDTO.onError("未接收到数据!");
             }
-            //初始、格式化数据
-            List<DoctorAdvice> doctorAdviceList=Lists.newArrayList();
-            List<ADoctorAdviceDTO> doctorAdviceDtoList=Lists.newArrayList();
-            list.stream().forEach(s->{
-                DoctorAdvice doctorAdvice=new DoctorAdvice();
-                BeanUtil.copyProperties(s,doctorAdvice);
-                if(StringUtil.isNotBlank(s.getDaStartDate())){
-                    doctorAdvice.setDaStartDate(DateUtil.parseDateTime(s.getDaStartDate()));
-                }
-                if(StringUtil.isNotBlank(s.getDaStopDate())){
-                    doctorAdvice.setDaStopDate(DateUtil.parseDateTime(s.getDaStopDate()));
-                }
-                doctorAdviceList.add(doctorAdvice);
-            });
-            execute(doctorAdviceList);
-            doctorAdviceDtoList=BeanUtil.listCopyTo(list,ADoctorAdviceDTO.class);
-            return RespDTO.onSuc(doctorAdviceDtoList);
-        }else{
-            return RespDTO.onError("未接收到数据!");
+        }catch (Exception e){
+            aMedAbnormalInfoFacade.saveAbnormalInfo(JSON.toJSONString(list),"",e.getMessage());
+            return RespDTO.onError(e.getMessage());
         }
     }
 
     public void execute(List<DoctorAdvice> doctorAdviceList){
-        List<DoctorAdvice> addE = Lists.newLinkedList();
-        List<DoctorAdvice> updateE = Lists.newLinkedList();
-        if (doctorAdviceList != null && doctorAdviceList.size() > 0) {
-            doctorAdviceList.stream().forEach(s -> {
-                DoctorAdvice doctorAdvice = this.getOne(new QueryWrapper<DoctorAdvice>()
-                        .eq("doctor_advice_id", s.getDoctorAdviceId())
-                        .eq("hospital_id", s.getHospitalId())
-                        .eq("behospital_code",s.getBehospitalCode()), false);
-                if (doctorAdvice != null) {
-                    s.setGmtModified(new Date());
-                    updateE.add(s);
-                } else {
-                    s.setGmtCreate(new Date());
-                    addE.add(s);
-                }
-            });
-        }
-        if(addE.size()>0){
-            doctorAdviceService.saveBatch(addE);
-        }
-        if(updateE.size()>0){
-            doctorAdviceService.updateBatchByKey(updateE);
+        try {
+            List<DoctorAdvice> addE = Lists.newLinkedList();
+            List<DoctorAdvice> updateE = Lists.newLinkedList();
+            if (doctorAdviceList != null && doctorAdviceList.size() > 0) {
+                doctorAdviceList.stream().forEach(s -> {
+                    DoctorAdvice doctorAdvice = this.getOne(new QueryWrapper<DoctorAdvice>()
+                            .eq("doctor_advice_id", s.getDoctorAdviceId())
+                            .eq("hospital_id", s.getHospitalId())
+                            .eq("behospital_code",s.getBehospitalCode()), false);
+                    if (doctorAdvice != null) {
+                        s.setGmtModified(new Date());
+                        updateE.add(s);
+                    } else {
+                        s.setGmtCreate(new Date());
+                        addE.add(s);
+                    }
+                });
+            }
+            if(addE.size()>0){
+                doctorAdviceService.saveBatch(addE);
+            }
+            if(updateE.size()>0){
+                doctorAdviceService.updateBatchByKey(updateE);
+            }
+        }catch (Exception e){
+            aMedAbnormalInfoFacade.saveAbnormalInfo(JSON.toJSONString(doctorAdviceList),"",e.getMessage());
         }
     }
 }

+ 17 - 1
src/main/java/com/diagbot/facade/data/AMedAbnormalInfoFacade.java

@@ -1,9 +1,25 @@
 package com.diagbot.facade.data;
 
+import com.diagbot.entity.MedAbnormalInfo;
 import com.diagbot.service.impl.MedAbnormalInfoServiceImpl;
 import org.springframework.stereotype.Component;
 
+import java.util.Date;
+
 @Component
 public class AMedAbnormalInfoFacade extends MedAbnormalInfoServiceImpl {
-
+    /**
+     * 接口日志记录
+     * @param paramIn
+     * @param paramOut
+     * @param remark
+     */
+    public 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());
+        this.save(medAbnormalInfo);
+    }
 }