|
@@ -0,0 +1,104 @@
|
|
|
+package com.diagbot.facade.data;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
+import com.diagbot.entity.MedPacsInfo;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.service.impl.MedPacsInfoServiceImpl;
|
|
|
+import com.diagbot.util.DateUtil;
|
|
|
+import com.diagbot.util.SqlProperties;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
+import com.diagbot.util.TZDBConn;
|
|
|
+import com.diagbot.vo.data.ADeleteFlagVO;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Component
|
|
|
+public class AMedPacsInfoFacade extends MedPacsInfoServiceImpl {
|
|
|
+ private TZDBConn tzDBConn = new TZDBConn();
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SqlProperties sqlProperties;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("medPacsInfoServiceImpl")
|
|
|
+ private MedPacsInfoServiceImpl medPacsInfoServiceImpl;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AMedAbnormalInfoFacade aMedAbnormalInfoFacade;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 同步前一天
|
|
|
+ */
|
|
|
+ public void executeMedPacsResult() {
|
|
|
+ //String sql="select * from br_rechome where cjcxrq>=dateadd(day,-2,getdate()) and cjcxrq<=getdate()";
|
|
|
+ //同步前一天的数据
|
|
|
+ //String sql="select * from br_rechome where cjcxrq>=(select CONVERT(varchar,GETDATE()-2,23)) and cjcxrq<(select CONVERT(varchar,GETDATE(),23))";
|
|
|
+ String sql = sqlProperties.getPacsInfoSql();
|
|
|
+ List<MedPacsInfo> medPacsInfoList= tzDBConn.getPacsInfo(sql);
|
|
|
+ execute(medPacsInfoList);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void execute(List<MedPacsInfo> medPacsInfoList){
|
|
|
+ try {
|
|
|
+ List<MedPacsInfo> addE = Lists.newLinkedList();
|
|
|
+ List<MedPacsInfo> updateE = Lists.newLinkedList();
|
|
|
+ if (medPacsInfoList != null && medPacsInfoList.size() > 0) {
|
|
|
+ medPacsInfoList.stream().forEach(s -> {
|
|
|
+ MedPacsInfo medPacsInfo = this.getOne(new QueryWrapper<MedPacsInfo>()
|
|
|
+ .eq("rep_no", s.getRepNo())
|
|
|
+ .eq("hospital_id", s.getHospitalId()), false);
|
|
|
+ if (medPacsInfo != null) {
|
|
|
+ s.setGmtModified(new Date());
|
|
|
+ updateE.add(s);
|
|
|
+ } else {
|
|
|
+ s.setGmtCreate(new Date());
|
|
|
+ addE.add(s);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if(addE.size()>0){
|
|
|
+ medPacsInfoServiceImpl.saveBatch(addE);
|
|
|
+ }
|
|
|
+ if(updateE.size()>0){
|
|
|
+ this.baseMapper.updateBatchByKey(updateE);
|
|
|
+ }
|
|
|
+ //aMedAbnormalInfoFacade.saveAbnormalInfo("检查",JSON.toJSONString(medPacsResultList),"","操作成功!");
|
|
|
+ }catch (Exception e){
|
|
|
+ aMedAbnormalInfoFacade.saveAbnormalInfo("检查信息-保存异常",JSON.toJSONString(medPacsInfoList),"",e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public RespDTO deleteFlag(ADeleteFlagVO aDeleteFlagVO){
|
|
|
+ try {
|
|
|
+ //验证数据是否存在
|
|
|
+ if(StringUtil.isEmpty(aDeleteFlagVO.getRepNo())){
|
|
|
+ return RespDTO.onError("请输入报告单号!");
|
|
|
+ }else if(aDeleteFlagVO.getHospitalId()==null){
|
|
|
+ return RespDTO.onError("请输入医院编码!");
|
|
|
+ }else {
|
|
|
+ UpdateWrapper<MedPacsInfo> updateWrapper=new UpdateWrapper<>();
|
|
|
+ updateWrapper.eq("rep_no", aDeleteFlagVO.getRepNo())
|
|
|
+ .eq("hospital_id", aDeleteFlagVO.getHospitalId())
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N)
|
|
|
+ .set("is_deleted",IsDeleteEnum.Y)
|
|
|
+ .set("gmt_modified", DateUtil.now());
|
|
|
+
|
|
|
+ Boolean flag=update(new MedPacsInfo(),updateWrapper);
|
|
|
+ //aMedAbnormalInfoFacade.saveAbnormalInfo("检查-删除",JSON.toJSONString(aDeleteFlagVO),JSON.toJSONString(RespDTO.onSuc(flag)),"操作成功!");
|
|
|
+ return RespDTO.onSuc(flag);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ aMedAbnormalInfoFacade.saveAbnormalInfo("检查信息-删除异常", JSON.toJSONString(aDeleteFlagVO),"",e.getMessage());
|
|
|
+ return RespDTO.onError(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|