Browse Source

管理端错误

whszxyjhyy
zhangye 1 month ago
parent
commit
b6c99fa49b
  1. 274
      ruisi_java/ruisi-web-admin/src/main/java/com/ccsens/admin/service/impl/PmsPatientServiceImpl.java

274
ruisi_java/ruisi-web-admin/src/main/java/com/ccsens/admin/service/impl/PmsPatientServiceImpl.java

@ -201,155 +201,147 @@ public class PmsPatientServiceImpl implements IPmsPatientService {
@Override
public Long editPatientOtherMsg(PmsPatientDto.EditOtherMsg param) {
JSONObject jsonObject = null;
Object model = param.getModel();
// 处理model参数
if (model instanceof List) {
// List转JSONArray
com.alibaba.fastjson2.JSONArray array = (com.alibaba.fastjson2.JSONArray) JSON.toJSON(model);
jsonObject = array.getJSONObject(0);
} else if (model instanceof Map) {
// Map转JSONObject
jsonObject = (JSONObject) JSON.toJSON(model);
}
// JSONObject jsonObject = null;
// if (param.getModel() instanceof JSONArray) {
// JSONArray array = (JSONArray) param.getModel();
// Object model = param.getModel();
//
// // 处理model参数
// if (model instanceof List) {
// // List转JSONArray
// com.alibaba.fastjson2.JSONArray array = (com.alibaba.fastjson2.JSONArray) JSON.toJSON(model);
// jsonObject = array.getJSONObject(0);
// } else if (param.getModel() instanceof JSONObject) {
// jsonObject = (JSONObject) param.getModel();
// } else if (model instanceof Map) {
// // Map转JSONObject
// jsonObject = (JSONObject) JSON.toJSON(model);
// }
//
// //验证就诊号是否为空
// String visitNo = jsonObject.getString("outpatientNo");
// if (StrUtil.isEmpty(visitNo)) {
// visitNo = jsonObject.getString("visitNo");
// if (StrUtil.isEmpty(visitNo)) {
// throw new ServiceException("就诊号不能为空");
// }
// }
// //验证患者id是否为空
// Long patientId = jsonObject.getLong("patientId");
// if (patientId == null) {
// throw new ServiceException("患者id不能为空");
// }
//
//
// //如果是就诊信息(PmsPatientBody)
// if ("PmsPatientBody".equals(param.getEditType())) {
// //就诊信息默认是单个信息,直接用jsonObject
// PmsPatientBody pmsPatientBody = JSONObject.parseObject(jsonObject.toJSONString(), PmsPatientBody.class);
// //根据就诊号和患者id查询就诊信息是否存在
// PmsPatientBodyExample patientBodyExample = new PmsPatientBodyExample();
// patientBodyExample.createCriteria().andOutpatientNoEqualTo(visitNo).andPatientIdEqualTo(patientId)
// .andDelFlagEqualTo((byte) 0);
// List<PmsPatientBody> pmsPatientBodies = pmsPatientBodyMapper.selectByExample(patientBodyExample);
// if (CollUtil.isNotEmpty(pmsPatientBodies)) {
// //存在则修改
// PmsPatientBody oldPatientBody = pmsPatientBodies.get(0);
// pmsPatientBody.setId(oldPatientBody.getId());
// pmsPatientBodyMapper.updateByPrimaryKeySelective(pmsPatientBody);
// } else {
// //不存在则添加
// pmsPatientBody.setId(IDGenerator.nextSnowflakeId());
// pmsPatientBodyMapper.insertSelective(pmsPatientBody);
// }
// } else if ("PmsPatientPersonal".equals(param.getEditType())) {
// //烟酒史默认是单个信息,直接用jsonObject
// //烟酒史
// PmsPatientPersonal pmsPatientPersonal = JSONObject.parseObject(jsonObject.toJSONString(), PmsPatientPersonal.class);
// //根据就诊号和患者id查询就诊信息是否存在
// PmsPatientPersonalExample patientPersonalExample = new PmsPatientPersonalExample();
// patientPersonalExample.createCriteria().andVisitNoEqualTo(visitNo).andPatientIdEqualTo(patientId)
// .andDelFlagEqualTo((byte) 0);
// List<PmsPatientPersonal> pmsPatientPersonals = pmsPatientPersonalMapper.selectByExample(patientPersonalExample);
// if (CollUtil.isNotEmpty(pmsPatientPersonals)) {
// //存在则修改
// PmsPatientPersonal oldPatientPersonal = pmsPatientPersonals.get(0);
// pmsPatientPersonal.setId(oldPatientPersonal.getId());
// pmsPatientPersonalMapper.updateByPrimaryKeySelective(pmsPatientPersonal);
// } else {
// //不存在则添加
// pmsPatientPersonal.setId(IDGenerator.nextSnowflakeId());
// pmsPatientPersonalMapper.insertSelective(pmsPatientPersonal);
// }
// }else if ("PmsPatientParentIllness".equals(param.getEditType())) {
// //根据就诊号和患者id删除旧的用药信息(修改删除状态)
// PmsPatientParentIllnessExample patientParentIllnessExample = new PmsPatientParentIllnessExample();
// patientParentIllnessExample.createCriteria().andVisitNoEqualTo(visitNo).andPatientIdEqualTo(patientId)
// .andDelFlagEqualTo((byte) 0);
// PmsPatientParentIllness illness = new PmsPatientParentIllness();
// illness.setDelFlag((byte) 1);
// pmsPatientParentIllnessMapper.updateByExampleSelective(illness, patientParentIllnessExample);
// //诊断用药为多个
// com.alibaba.fastjson2.JSONArray array = (com.alibaba.fastjson2.JSONArray) JSON.toJSON(model);
// for (int i = 0; i < array.size(); i++) {
// PmsPatientParentIllness pmsPatientParentIllness = JSONObject.parseObject(array.getJSONObject(i).toJSONString(), PmsPatientParentIllness.class);
// pmsPatientParentIllness.setId(IDGenerator.nextSnowflakeId());
// pmsPatientParentIllnessMapper.insertSelective(pmsPatientParentIllness);
// }
// }else if ("PmsPatientDiagnosis".equals(param.getEditType())) {
// //删除旧的诊断信息(修改删除状态)
// PmsPatientDiagnosisExample patientDiagnosisExample = new PmsPatientDiagnosisExample();
// patientDiagnosisExample.createCriteria().andVisitNoEqualTo(visitNo).andPatientIdEqualTo(patientId)
// .andDelFlagEqualTo((byte) 0);
// PmsPatientDiagnosis diagnosis = new PmsPatientDiagnosis();
// diagnosis.setDelFlag((byte) 1);
// pmsPatientDiagnosisMapper.updateByExampleSelective(diagnosis, patientDiagnosisExample);
// //诊断默认是多个信息,用jsonArray
// com.alibaba.fastjson2.JSONArray array = (com.alibaba.fastjson2.JSONArray) JSON.toJSON(model);
// for (int i = 0; i < array.size(); i++) {
// PmsPatientDiagnosis pmsPatientDiagnosis = JSONObject.parseObject(array.getJSONObject(i).toJSONString(), PmsPatientDiagnosis.class);
// pmsPatientDiagnosis.setId(IDGenerator.nextSnowflakeId());
// pmsPatientDiagnosisMapper.insertSelective(pmsPatientDiagnosis);
// }
// }
//验证就诊号是否为空
String visitNo = jsonObject.getString("outpatientNo");
if (StrUtil.isEmpty(visitNo)) {
visitNo = jsonObject.getString("visitNo");
if (StrUtil.isEmpty(visitNo)) {
throw new ServiceException("就诊号不能为空");
}
}
//验证患者id是否为空
Long patientId = jsonObject.getLong("patientId");
if (patientId == null) {
throw new ServiceException("患者id不能为空");
}
//如果是就诊信息(PmsPatientBody)
if ("PmsPatientBody".equals(param.getEditType())) {
//就诊信息默认是单个信息,直接用jsonObject
PmsPatientBody pmsPatientBody = JSONObject.parseObject(jsonObject.toJSONString(), PmsPatientBody.class);
//根据就诊号和患者id查询就诊信息是否存在
PmsPatientBodyExample patientBodyExample = new PmsPatientBodyExample();
patientBodyExample.createCriteria().andOutpatientNoEqualTo(visitNo).andPatientIdEqualTo(patientId)
.andDelFlagEqualTo((byte) 0);
List<PmsPatientBody> pmsPatientBodies = pmsPatientBodyMapper.selectByExample(patientBodyExample);
if (CollUtil.isNotEmpty(pmsPatientBodies)) {
//存在则修改
PmsPatientBody oldPatientBody = pmsPatientBodies.get(0);
pmsPatientBody.setId(oldPatientBody.getId());
pmsPatientBodyMapper.updateByPrimaryKeySelective(pmsPatientBody);
} else {
//不存在则添加
pmsPatientBody.setId(IDGenerator.nextSnowflakeId());
pmsPatientBodyMapper.insertSelective(pmsPatientBody);
}
} else if ("PmsPatientPersonal".equals(param.getEditType())) {
//烟酒史默认是单个信息,直接用jsonObject
//烟酒史
PmsPatientPersonal pmsPatientPersonal = JSONObject.parseObject(jsonObject.toJSONString(), PmsPatientPersonal.class);
//根据就诊号和患者id查询就诊信息是否存在
PmsPatientPersonalExample patientPersonalExample = new PmsPatientPersonalExample();
patientPersonalExample.createCriteria().andVisitNoEqualTo(visitNo).andPatientIdEqualTo(patientId)
.andDelFlagEqualTo((byte) 0);
List<PmsPatientPersonal> pmsPatientPersonals = pmsPatientPersonalMapper.selectByExample(patientPersonalExample);
if (CollUtil.isNotEmpty(pmsPatientPersonals)) {
//存在则修改
PmsPatientPersonal oldPatientPersonal = pmsPatientPersonals.get(0);
pmsPatientPersonal.setId(oldPatientPersonal.getId());
pmsPatientPersonalMapper.updateByPrimaryKeySelective(pmsPatientPersonal);
try {
String type = param.getEditType();
JSONObject json = (JSONObject) JSON.toJSON(param.getModel());
Object bean = SpringContextUtils.getBean(type.substring(0, 1).toLowerCase() + type.substring(1) + "Mapper");
//有id则修改,无则添加
String methodName;
String id = "id";
String createBy = "createBy";
String updateBy = "updateBy";
String recorder = "recorder";
if (json.getLong(id) == null || json.getLong(id) == 0) {
methodName = "insertSelective";
json.put(id, IDGenerator.nextSnowflakeId());
json.put(createBy, SecurityUtils.getUsername());
json.put(recorder, SecurityUtils.getUserId());
} else {
//不存在则添加
pmsPatientPersonal.setId(IDGenerator.nextSnowflakeId());
pmsPatientPersonalMapper.insertSelective(pmsPatientPersonal);
}
}else if ("PmsPatientParentIllness".equals(param.getEditType())) {
//根据就诊号和患者id删除旧的用药信息(修改删除状态)
PmsPatientParentIllnessExample patientParentIllnessExample = new PmsPatientParentIllnessExample();
patientParentIllnessExample.createCriteria().andVisitNoEqualTo(visitNo).andPatientIdEqualTo(patientId)
.andDelFlagEqualTo((byte) 0);
PmsPatientParentIllness illness = new PmsPatientParentIllness();
illness.setDelFlag((byte) 1);
pmsPatientParentIllnessMapper.updateByExampleSelective(illness, patientParentIllnessExample);
//诊断用药为多个
com.alibaba.fastjson2.JSONArray array = (com.alibaba.fastjson2.JSONArray) JSON.toJSON(model);
for (int i = 0; i < array.size(); i++) {
PmsPatientParentIllness pmsPatientParentIllness = JSONObject.parseObject(array.getJSONObject(i).toJSONString(), PmsPatientParentIllness.class);
pmsPatientParentIllness.setId(IDGenerator.nextSnowflakeId());
pmsPatientParentIllnessMapper.insertSelective(pmsPatientParentIllness);
}
}else if ("PmsPatientDiagnosis".equals(param.getEditType())) {
//删除旧的诊断信息(修改删除状态)
PmsPatientDiagnosisExample patientDiagnosisExample = new PmsPatientDiagnosisExample();
patientDiagnosisExample.createCriteria().andVisitNoEqualTo(visitNo).andPatientIdEqualTo(patientId)
.andDelFlagEqualTo((byte) 0);
PmsPatientDiagnosis diagnosis = new PmsPatientDiagnosis();
diagnosis.setDelFlag((byte) 1);
pmsPatientDiagnosisMapper.updateByExampleSelective(diagnosis, patientDiagnosisExample);
//诊断默认是多个信息,用jsonArray
com.alibaba.fastjson2.JSONArray array = (com.alibaba.fastjson2.JSONArray) JSON.toJSON(model);
for (int i = 0; i < array.size(); i++) {
PmsPatientDiagnosis pmsPatientDiagnosis = JSONObject.parseObject(array.getJSONObject(i).toJSONString(), PmsPatientDiagnosis.class);
pmsPatientDiagnosis.setId(IDGenerator.nextSnowflakeId());
pmsPatientDiagnosisMapper.insertSelective(pmsPatientDiagnosis);
methodName = "updateByPrimaryKeySelective";
json.put(updateBy, SecurityUtils.getUsername());
}
log.info("{}:{}", methodName, json);
//请求参数
Class<?> modelClass = Class.forName("com.ccsens.system.domain.po." + type);
Object model = json.toJavaObject(modelClass);
//方法
Method method = bean.getClass().getMethod(methodName, modelClass);
log.info("method:{}", method);
//方法调用(保存/修改)
method.invoke(bean, model);
return json.getLong("id");
} catch (ClassNotFoundException e) {
log.error("编辑病人其他信息反射异常", e);
throw new BaseException(ErrorConstant.PARAM_ERROR);
} catch (NoSuchMethodException e) {
log.error("编辑病人其他信息反射异常", e);
throw new BaseException(ErrorConstant.PARAM_ERROR);
} catch (IllegalAccessException e) {
log.error("编辑病人其他信息反射异常", e);
throw new BaseException(ErrorConstant.PARAM_ERROR);
} catch (InvocationTargetException e) {
log.error("编辑病人其他信息反射异常", e);
throw new BaseException(ErrorConstant.PARAM_ERROR);
}
// try {
// String type = param.getEditType();
// JSONObject json = param.getModel();
// Object bean = SpringContextUtils.getBean(type.substring(0, 1).toLowerCase() + type.substring(1) + "Mapper");
// //有id则修改,无则添加
// String methodName;
// String id = "id";
// String createBy = "createBy";
// String updateBy = "updateBy";
// String recorder = "recorder";
// if (json.getLong(id) == null || json.getLong(id) == 0) {
// methodName = "insertSelective";
// json.put(id, IDGenerator.nextSnowflakeId());
// json.put(createBy, SecurityUtils.getUsername());
// json.put(recorder, SecurityUtils.getUserId());
// } else {
// methodName = "updateByPrimaryKeySelective";
// json.put(updateBy, SecurityUtils.getUsername());
// }
// log.info("{}:{}", methodName, json);
// //请求参数
// Class<?> modelClass = Class.forName("com.ccsens.system.domain.po." + type);
// Object model = json.toJavaObject(modelClass);
// //方法
// Method method = bean.getClass().getMethod(methodName, modelClass);
// log.info("method:{}", method);
// //方法调用(保存/修改)
// method.invoke(bean, model);
// return json.getLong("id");
// } catch (ClassNotFoundException e) {
// log.error("编辑病人其他信息反射异常", e);
// throw new BaseException(ErrorConstant.PARAM_ERROR);
// } catch (NoSuchMethodException e) {
// log.error("编辑病人其他信息反射异常", e);
// throw new BaseException(ErrorConstant.PARAM_ERROR);
// } catch (IllegalAccessException e) {
// log.error("编辑病人其他信息反射异常", e);
// throw new BaseException(ErrorConstant.PARAM_ERROR);
// } catch (InvocationTargetException e) {
// log.error("编辑病人其他信息反射异常", e);
// throw new BaseException(ErrorConstant.PARAM_ERROR);
// }
return null;
}
@Override

Loading…
Cancel
Save