|
@@ -9,6 +9,7 @@ import com.diagbot.dto.data.ColumnZhAndChDTO;
|
|
|
import com.diagbot.entity.MedicalRecord;
|
|
|
import com.diagbot.entity.MedicalRecordContent;
|
|
|
import com.diagbot.entity.StrAdmissionNote;
|
|
|
+import com.diagbot.enums.CacheKeyEnum;
|
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
|
import com.diagbot.entity.StrWardRecord;
|
|
|
import com.diagbot.service.impl.StrWardRecordServiceImpl;
|
|
@@ -23,10 +24,8 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.lang.reflect.Field;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Component
|
|
|
public class AStrWardRecordFacade extends StrWardRecordServiceImpl {
|
|
@@ -84,16 +83,30 @@ public class AStrWardRecordFacade extends StrWardRecordServiceImpl {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public void dealData(StrWardRecord medWardRecord){
|
|
|
+ public void dealData(StrWardRecord medWardRecord,String modelName){
|
|
|
try {
|
|
|
+ Map<String,Object> listMap =this.objectToMap(medWardRecord);
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ //得到表所对应的中文名和英文名
|
|
|
+ Map<String,String> tableKey=columnFacade.getColumn(CacheKeyEnum.getName(modelName));
|
|
|
+ if (listMap.size()>0){
|
|
|
+ listMap.forEach((k,v)->{
|
|
|
+ tableKey.forEach((tableK,tableV)->{
|
|
|
+ if (k.equals(tableV) && null!=v){
|
|
|
+ map.put(tableK,v);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
//判断数据库中是否存在,不存在insert
|
|
|
if(isExist(medWardRecord)){
|
|
|
medWardRecord.setGmtCreate(new Date());//记录创建时间
|
|
|
- medWardRecord.setWholeData(JSON.toJSONString(medWardRecord));
|
|
|
+ medWardRecord.setWholeData(JSON.toJSONString(map));
|
|
|
this.save(medWardRecord);
|
|
|
}else{
|
|
|
medWardRecord.setGmtModified(new Date());//记录修改时间
|
|
|
- medWardRecord.setWholeData(JSON.toJSONString(medWardRecord));
|
|
|
+ medWardRecord.setWholeData(JSON.toJSONString(map));
|
|
|
this.update(medWardRecord,new QueryWrapper<StrWardRecord>()
|
|
|
.eq("rec_id", medWardRecord.getRecId())
|
|
|
.eq("hospital_id", medWardRecord.getHospitalId())
|
|
@@ -147,4 +160,18 @@ public class AStrWardRecordFacade extends StrWardRecordServiceImpl {
|
|
|
return RespDTO.onError(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private Map<String,Object> objectToMap(Object o) throws IllegalAccessException {
|
|
|
+ if(null == o){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ Field[] declaredFields = o.getClass().getDeclaredFields();
|
|
|
+ for (Field field :declaredFields) {
|
|
|
+ // (此处如果不设置 无法获取对象的私有属性)
|
|
|
+ field.setAccessible(true);
|
|
|
+ map.put(field.getName(),field.get(o));
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
}
|