|
|
@@ -2,41 +2,59 @@ package com.fs.app.facade.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.fs.app.facade.Hospital580FacadeService;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.hospital580.dto.DiseaseDto;
|
|
|
import com.fs.hospital580.dto.PreDemandDto;
|
|
|
import com.fs.hospital580.dto.Result580;
|
|
|
-import com.fs.hospital580.entity.FsStoreHospital580OrderScrmEntity;
|
|
|
-import com.fs.hospital580.entity.FsStoreHospital580PrescriptionMedicineScrmEntity;
|
|
|
-import com.fs.hospital580.entity.FsStoreHospital580PrescriptionScrmEntity;
|
|
|
-import com.fs.hospital580.entity.FsStoreHospital580ProductPushScrmEntity;
|
|
|
+import com.fs.hospital580.entity.*;
|
|
|
+import com.fs.hospital580.service.FsStoreHospital580AnswerScrmService;
|
|
|
import com.fs.hospital580.service.Hospital580Service;
|
|
|
import com.fs.hospital580.vo.*;
|
|
|
+import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class Hospital580FacadeServiceImpl implements Hospital580FacadeService {
|
|
|
+
|
|
|
@Autowired
|
|
|
private Hospital580Service hospital580Service;
|
|
|
@Autowired
|
|
|
- private FsStoreHospital580ProductPushScrmEntity productPushScrm;
|
|
|
+ private FsStoreHospital580AnswerScrmService answerScrmService;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public R initPreDemand(FsStoreHospital580OrderScrmVo vo) {
|
|
|
+ // 保存问诊信息
|
|
|
FsStoreHospital580OrderScrmEntity order = new FsStoreHospital580OrderScrmEntity();
|
|
|
BeanUtil.copyProperties(vo, order);
|
|
|
order.insert();
|
|
|
+ List<FsStoreHospital580AnswerScrmEntity> answerScrmEntities = vo.getBeforeAiDataList().stream().map(item -> {
|
|
|
+ FsStoreHospital580AnswerScrmEntity answerScrmEntity = new FsStoreHospital580AnswerScrmEntity();
|
|
|
+ BeanUtil.copyProperties(item, answerScrmEntity);
|
|
|
+ answerScrmEntity.setOrderId(order.getOrderId());
|
|
|
+ return answerScrmEntity;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ answerScrmService.saveBatch(answerScrmEntities);
|
|
|
+
|
|
|
+ // 获取问诊链接
|
|
|
PreDemandDto dto = new PreDemandDto();
|
|
|
BeanUtil.copyProperties(vo, dto);
|
|
|
dto.setBizOrderId(order.getOrderId().toString());
|
|
|
- return processResult(hospital580Service.initPreDemand(dto));
|
|
|
+ // 解析返回值
|
|
|
+ Result580 result580 = hospital580Service.initPreDemand(dto);
|
|
|
+ order.setJumpUrl(result580.getData());
|
|
|
+ order.updateById();
|
|
|
+ return processResult(result580);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -46,15 +64,14 @@ public class Hospital580FacadeServiceImpl implements Hospital580FacadeService {
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void prescription(Map<String, Object> map) {
|
|
|
- FsStoreHospital580PrescriptionScrmVo properties = BeanUtil.copyProperties(map, FsStoreHospital580PrescriptionScrmVo.class);
|
|
|
+ public void prescription(FsStoreHospital580PrescriptionScrmVo vo) {
|
|
|
FsStoreHospital580PrescriptionScrmEntity prescription = new FsStoreHospital580PrescriptionScrmEntity();
|
|
|
- BeanUtil.copyProperties(properties, prescription);
|
|
|
- prescription.setOrderId(properties.getBizOrderId());
|
|
|
+ BeanUtil.copyProperties(vo, prescription);
|
|
|
+ prescription.setOrderId(vo.getBizOrderId());
|
|
|
// 插入处方记录
|
|
|
prescription.insert();
|
|
|
|
|
|
- List<FsStoreHospital580PrescriptionMedicineScrmVo> drugRspList = properties.getDrugRspList();
|
|
|
+ List<FsStoreHospital580PrescriptionMedicineScrmVo> drugRspList = vo.getDrugRspList();
|
|
|
drugRspList.forEach(item -> {
|
|
|
FsStoreHospital580PrescriptionMedicineScrmEntity entity = new FsStoreHospital580PrescriptionMedicineScrmEntity();
|
|
|
BeanUtil.copyProperties(item, entity);
|
|
|
@@ -63,53 +80,56 @@ public class Hospital580FacadeServiceImpl implements Hospital580FacadeService {
|
|
|
});
|
|
|
// 修改问诊单处方状态
|
|
|
FsStoreHospital580OrderScrmEntity order = new FsStoreHospital580OrderScrmEntity();
|
|
|
- order.setOrderId(Long.valueOf(properties.getBizOrderId()));
|
|
|
+ order.setOrderId(Long.valueOf(vo.getBizOrderId()));
|
|
|
order.setPrescriptionStatus((byte) 1);
|
|
|
order.updateById();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void refusePrescription(Map<String, Object> map) {
|
|
|
+ public void refusePrescription(RefusePrescriptionVo vo) {
|
|
|
// 修改处方信息
|
|
|
- RefusePrescriptionVo prescriptionVo = BeanUtil.copyProperties(map, RefusePrescriptionVo.class);
|
|
|
FsStoreHospital580OrderScrmEntity order = new FsStoreHospital580OrderScrmEntity();
|
|
|
- order.setOrderId(Long.valueOf(prescriptionVo.getBizOrderId()));
|
|
|
+ order.setOrderId(Long.valueOf(vo.getBizOrderId()));
|
|
|
order.setPrescriptionStatus((byte) 2);
|
|
|
- order.setReason(prescriptionVo.getReason());
|
|
|
+ order.setReason(vo.getReason());
|
|
|
order.updateById();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void reviewPrescription(Map<String, Object> map) {
|
|
|
- ReviewPrescriptionVo prescriptionVo = BeanUtil.copyProperties(map, ReviewPrescriptionVo.class);
|
|
|
- if (ObjectUtil.isEmpty(prescriptionVo) || ObjectUtil.isEmpty(prescriptionVo.getPid())) {
|
|
|
+ public void reviewPrescription(ReviewPrescriptionVo vo) {
|
|
|
+ if (ObjectUtil.isEmpty(vo) || ObjectUtil.isEmpty(vo.getPid())) {
|
|
|
return;
|
|
|
}
|
|
|
// 修改处方信息
|
|
|
FsStoreHospital580PrescriptionScrmEntity prescription = new FsStoreHospital580PrescriptionScrmEntity();
|
|
|
prescription.update(new LambdaUpdateWrapper<FsStoreHospital580PrescriptionScrmEntity>()
|
|
|
- .eq(FsStoreHospital580PrescriptionScrmEntity::getPid, prescriptionVo.getPid())
|
|
|
- .set(FsStoreHospital580PrescriptionScrmEntity::getAuditStatus, prescriptionVo.getAuditStatus())
|
|
|
- .set(FsStoreHospital580PrescriptionScrmEntity::getAudiTime, prescriptionVo.getAuditTime())
|
|
|
- .set(FsStoreHospital580PrescriptionScrmEntity::getAuditApothecaryName, prescriptionVo.getAuditApothecaryName())
|
|
|
- .set(FsStoreHospital580PrescriptionScrmEntity::getReason, prescriptionVo.getReason())
|
|
|
- .set(FsStoreHospital580PrescriptionScrmEntity::getDstFilePath, prescriptionVo.getDstFilePath()));
|
|
|
+ .eq(FsStoreHospital580PrescriptionScrmEntity::getPId, vo.getPid())
|
|
|
+ .set(FsStoreHospital580PrescriptionScrmEntity::getAuditStatus, vo.getAuditStatus())
|
|
|
+ .set(FsStoreHospital580PrescriptionScrmEntity::getAudiTime, vo.getAuditTime())
|
|
|
+ .set(FsStoreHospital580PrescriptionScrmEntity::getAuditApothecaryName, vo.getAuditApothecaryName())
|
|
|
+ .set(FsStoreHospital580PrescriptionScrmEntity::getReason, vo.getReason())
|
|
|
+ .set(FsStoreHospital580PrescriptionScrmEntity::getDstFilePath, vo.getDstFilePath()));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void medicineSync(Map<String, Object> map) {
|
|
|
- MedicineSyncVo medicineSyncVo = BeanUtil.copyProperties(map, MedicineSyncVo.class);
|
|
|
+ public void medicineSync(MedicineSyncVo vo) {
|
|
|
+ FsStoreHospital580ProductPushScrmEntity productPushScrm = new FsStoreHospital580ProductPushScrmEntity();
|
|
|
+ List<String> medicineIdList = JSONUtil.toList(JSONUtil.parseArray(vo.getMedicineIds()), String.class);
|
|
|
+ List<Long> medicineIds = medicineIdList.stream()
|
|
|
+ .map(Long::valueOf)
|
|
|
+ .collect(Collectors.toList());
|
|
|
productPushScrm.update(new LambdaUpdateWrapper<FsStoreHospital580ProductPushScrmEntity>()
|
|
|
- .in(FsStoreHospital580ProductPushScrmEntity::getProductId, medicineSyncVo.getMedicineIds())
|
|
|
- .set(FsStoreHospital580ProductPushScrmEntity::getPushStatus, medicineSyncVo.getErrCode().equals("0") ? 1 : 2)
|
|
|
- .set(FsStoreHospital580ProductPushScrmEntity::getErrMsg, medicineSyncVo.getErrMsg()));
|
|
|
+ .in(FsStoreHospital580ProductPushScrmEntity::getProductId, medicineIds)
|
|
|
+ .set(FsStoreHospital580ProductPushScrmEntity::getPushStatus, vo.getErrCode().equals("0") ? 1 : 2)
|
|
|
+ .set(FsStoreHospital580ProductPushScrmEntity::getErrMsg, vo.getErrMsg())
|
|
|
+ .set(FsStoreHospital580ProductPushScrmEntity::getUpdateTime, LocalDateTime.now()));
|
|
|
}
|
|
|
|
|
|
private R processResult(Result580 result580) {
|
|
|
if (0 == result580.getErr()) {
|
|
|
return R.ok().put("data", result580.getData());
|
|
|
}
|
|
|
- return R.error(result580.getErrmsg());
|
|
|
+ throw new RuntimeException(result580.getErrmsg());
|
|
|
}
|
|
|
|
|
|
}
|