|
|
@@ -1,24 +1,43 @@
|
|
|
package com.fs.app.facade.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.thread.ThreadUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fs.app.facade.Hospital580FacadeService;
|
|
|
-import com.fs.common.core.domain.R;
|
|
|
+import com.fs.common.core.domain.PageResponse;
|
|
|
+import com.fs.common.core.domain.Result;
|
|
|
+import com.fs.common.core.page.PageRequest;
|
|
|
import com.fs.hospital580.dto.DiseaseDto;
|
|
|
import com.fs.hospital580.dto.PreDemandDto;
|
|
|
import com.fs.hospital580.dto.Result580;
|
|
|
+import com.fs.hospital580.dto.TextRecordDto;
|
|
|
import com.fs.hospital580.entity.*;
|
|
|
-import com.fs.hospital580.service.FsStoreHospital580AnswerScrmService;
|
|
|
+import com.fs.hospital580.service.Hospital580PrescriptionAnswerScrmService;
|
|
|
+import com.fs.hospital580.service.Hospital580PrescriptionScrmService;
|
|
|
import com.fs.hospital580.service.Hospital580Service;
|
|
|
-import com.fs.hospital580.vo.*;
|
|
|
+import com.fs.hospital580.vo.MedicineSyncVo;
|
|
|
+import com.fs.hospital580.vo.PrescriptionMedicineScrmVo;
|
|
|
+import com.fs.hospital580.vo.RefusePrescriptionVo;
|
|
|
+import com.fs.hospital580.vo.ReviewPrescriptionVo;
|
|
|
+import com.fs.hospital580.vo.req.DiseaseReq;
|
|
|
+import com.fs.hospital580.vo.req.Prescription580Req;
|
|
|
+import com.fs.hospital580.vo.req.SaveOrderScrmReq;
|
|
|
+import com.fs.hospital580.vo.res.DiseaseQueryRes;
|
|
|
+import com.fs.hospital580.vo.res.PrescriptionDetailRes;
|
|
|
+import com.fs.hospital580.vo.res.PrescriptionListRes;
|
|
|
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.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@@ -27,20 +46,23 @@ public class Hospital580FacadeServiceImpl implements Hospital580FacadeService {
|
|
|
@Autowired
|
|
|
private Hospital580Service hospital580Service;
|
|
|
@Autowired
|
|
|
- private FsStoreHospital580AnswerScrmService answerScrmService;
|
|
|
+ private Hospital580PrescriptionAnswerScrmService answerScrmService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private Hospital580PrescriptionScrmService orderScrmService;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public R initPreDemand(OrderScrmVo vo) {
|
|
|
+ public Result<String> savePreDemand(SaveOrderScrmReq vo) {
|
|
|
// 保存问诊信息
|
|
|
- FsStoreHospital580OrderScrmEntity order = new FsStoreHospital580OrderScrmEntity();
|
|
|
+ Hospital580PrescriptionScrmEntity order = new Hospital580PrescriptionScrmEntity();
|
|
|
BeanUtil.copyProperties(vo, order);
|
|
|
order.insert();
|
|
|
- List<FsStoreHospital580AnswerScrmEntity> answerScrmEntities = vo.getBeforeAiDataList().stream().map(item -> {
|
|
|
- FsStoreHospital580AnswerScrmEntity answerScrmEntity = new FsStoreHospital580AnswerScrmEntity();
|
|
|
+ List<Hospital580PrescriptionAnswerScrmEntity> answerScrmEntities = vo.getBeforeAiDataList().stream().map(item -> {
|
|
|
+ Hospital580PrescriptionAnswerScrmEntity answerScrmEntity = new Hospital580PrescriptionAnswerScrmEntity();
|
|
|
BeanUtil.copyProperties(item, answerScrmEntity);
|
|
|
- answerScrmEntity.setOrderId(order.getOrderId());
|
|
|
+ answerScrmEntity.setPreId(order.getPreId());
|
|
|
return answerScrmEntity;
|
|
|
}).collect(Collectors.toList());
|
|
|
answerScrmService.saveBatch(answerScrmEntities);
|
|
|
@@ -48,7 +70,8 @@ public class Hospital580FacadeServiceImpl implements Hospital580FacadeService {
|
|
|
// 获取问诊链接
|
|
|
PreDemandDto dto = new PreDemandDto();
|
|
|
BeanUtil.copyProperties(vo, dto);
|
|
|
- dto.setBizOrderId(order.getOrderId().toString());
|
|
|
+ dto.setBizOrderId(order.getPreId().toString());
|
|
|
+ dto.setMemberId(vo.getUserFamilyPhone());
|
|
|
Result580 result580 = hospital580Service.initPreDemand(dto);
|
|
|
order.setJumpUrl(result580.getData());
|
|
|
order.updateById();
|
|
|
@@ -56,42 +79,58 @@ public class Hospital580FacadeServiceImpl implements Hospital580FacadeService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public R diseaseQuery(DiseaseVo vo) {
|
|
|
- return processResult(hospital580Service.disease(BeanUtil.copyProperties(vo, DiseaseDto.class)));
|
|
|
+ public PageResponse<DiseaseQueryRes> diseaseQuery(DiseaseReq req) {
|
|
|
+ Result<String> stringResult = processResult(hospital580Service.disease(BeanUtil.copyProperties(req, DiseaseDto.class)));
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(stringResult.getData());
|
|
|
+ return PageResponse.of(JSONUtil.toList(jsonObject.getJSONArray("list"), DiseaseQueryRes.class),
|
|
|
+ jsonObject.getInt("rowCount"),
|
|
|
+ req.getPageNum(),
|
|
|
+ req.getPageSize());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void prescription(PrescriptionScrmVo vo) {
|
|
|
- FsStoreHospital580PrescriptionScrmEntity prescription = new FsStoreHospital580PrescriptionScrmEntity();
|
|
|
+ public void prescription(Prescription580Req vo) {
|
|
|
+ // 处方信息
|
|
|
+ Hospital580PrescriptionScrmEntity prescription = orderScrmService.getById(vo.getBizOrderId());
|
|
|
BeanUtil.copyProperties(vo, prescription);
|
|
|
- prescription.setOrderId(vo.getBizOrderId());
|
|
|
- // 插入处方记录
|
|
|
- prescription.insert();
|
|
|
-
|
|
|
+ prescription.setPrescriptionStatus(vo.getStatus());
|
|
|
+ // 更新处方记录
|
|
|
+ prescription.updateById();
|
|
|
List<PrescriptionMedicineScrmVo> drugRspList = vo.getDrugRspList();
|
|
|
drugRspList.forEach(item -> {
|
|
|
- FsStoreHospital580PrescriptionMedicineScrmEntity entity = new FsStoreHospital580PrescriptionMedicineScrmEntity();
|
|
|
+ Hospital580PrescriptionMedicineScrmEntity entity = new Hospital580PrescriptionMedicineScrmEntity();
|
|
|
BeanUtil.copyProperties(item, entity);
|
|
|
entity.setPreId(prescription.getPreId());
|
|
|
// 插入药品信息
|
|
|
entity.insert();
|
|
|
});
|
|
|
- // 修改问诊单处方状态
|
|
|
- FsStoreHospital580OrderScrmEntity order = new FsStoreHospital580OrderScrmEntity();
|
|
|
- order.setOrderId(Long.valueOf(vo.getBizOrderId()));
|
|
|
- order.setPrescriptionStatus((byte) 1);
|
|
|
- order.updateById();
|
|
|
+
|
|
|
+ ThreadUtil.execute(() -> {
|
|
|
+ // 同步聊天记录
|
|
|
+ TextRecordDto build = TextRecordDto.builder().diagnosisId(prescription.getDiagnosisId()).pageSize(1).pageNum(100).build();
|
|
|
+ Result580 result580 = hospital580Service.textRecord(build);
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(result580.getData());
|
|
|
+ if (jsonObject.getInt("rowCount") > build.getPageSize()) {
|
|
|
+ build.setPageSize(jsonObject.getInt("rowCount"));
|
|
|
+ result580 = hospital580Service.textRecord(build);
|
|
|
+ jsonObject = JSONUtil.parseObj(result580.getData());
|
|
|
+ JSONArray data = jsonObject.getJSONArray("data");
|
|
|
+ Hospital580PrescriptionChatScrmEntity chatScrmEntity = new Hospital580PrescriptionChatScrmEntity();
|
|
|
+ chatScrmEntity.setContent(data.toString());
|
|
|
+ chatScrmEntity.setPreId(prescription.getPreId());
|
|
|
+ chatScrmEntity.insert();
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void refusePrescription(RefusePrescriptionVo vo) {
|
|
|
// 修改处方信息
|
|
|
- FsStoreHospital580OrderScrmEntity order = new FsStoreHospital580OrderScrmEntity();
|
|
|
- order.setOrderId(Long.valueOf(vo.getBizOrderId()));
|
|
|
- order.setPrescriptionStatus((byte) 2);
|
|
|
- order.setReason(vo.getReason());
|
|
|
- order.updateById();
|
|
|
+ Hospital580PrescriptionScrmEntity prescription = orderScrmService.getById(vo.getBizOrderId());
|
|
|
+ prescription.setReason(vo.getReason());
|
|
|
+ prescription.setPrescriptionStatus((byte) 2);
|
|
|
+ prescription.updateById();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -100,33 +139,68 @@ public class Hospital580FacadeServiceImpl implements Hospital580FacadeService {
|
|
|
return;
|
|
|
}
|
|
|
// 修改处方信息
|
|
|
- FsStoreHospital580PrescriptionScrmEntity prescription = new FsStoreHospital580PrescriptionScrmEntity();
|
|
|
- prescription.update(new LambdaUpdateWrapper<FsStoreHospital580PrescriptionScrmEntity>()
|
|
|
- .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()));
|
|
|
+ Hospital580PrescriptionScrmEntity prescription = new Hospital580PrescriptionScrmEntity();
|
|
|
+ prescription.update(new LambdaUpdateWrapper<Hospital580PrescriptionScrmEntity>()
|
|
|
+ .eq(Hospital580PrescriptionScrmEntity::getPid, vo.getPid())
|
|
|
+ .set(Hospital580PrescriptionScrmEntity::getAuditStatus, vo.getAuditStatus())
|
|
|
+ .set(Hospital580PrescriptionScrmEntity::getAuditTime, vo.getAuditTime())
|
|
|
+ .set(Hospital580PrescriptionScrmEntity::getAuditApothecaryName, vo.getAuditApothecaryName())
|
|
|
+ .set(Hospital580PrescriptionScrmEntity::getReason, vo.getReason())
|
|
|
+ .set(Hospital580PrescriptionScrmEntity::getDstFilePath, vo.getDstFilePath()));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void medicineSync(MedicineSyncVo vo) {
|
|
|
- FsStoreHospital580ProductPushScrmEntity productPushScrm = new FsStoreHospital580ProductPushScrmEntity();
|
|
|
+ Hospital580ProductPushScrmEntity productPushScrm = new Hospital580ProductPushScrmEntity();
|
|
|
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, medicineIds)
|
|
|
- .set(FsStoreHospital580ProductPushScrmEntity::getPushStatus, vo.getErrCode().equals("0") ? 1 : 2)
|
|
|
- .set(FsStoreHospital580ProductPushScrmEntity::getErrMsg, vo.getErrMsg())
|
|
|
- .set(FsStoreHospital580ProductPushScrmEntity::getUpdateTime, LocalDateTime.now()));
|
|
|
+ productPushScrm.update(new LambdaUpdateWrapper<Hospital580ProductPushScrmEntity>()
|
|
|
+ .in(Hospital580ProductPushScrmEntity::getProductId, medicineIds)
|
|
|
+ .set(Hospital580ProductPushScrmEntity::getPushStatus, vo.getErrCode().equals("0") ? 1 : 2)
|
|
|
+ .set(Hospital580ProductPushScrmEntity::getErrMsg, vo.getErrMsg())
|
|
|
+ .set(Hospital580ProductPushScrmEntity::getUpdateTime, LocalDateTime.now()));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageResponse<PrescriptionListRes> prescriptionList(String userId, PageRequest pageRequest) {
|
|
|
+ // 问诊列表
|
|
|
+ IPage<Hospital580PrescriptionScrmEntity> page = orderScrmService.page(
|
|
|
+ new Page<Hospital580PrescriptionScrmEntity>(pageRequest.getPageNum(), pageRequest.getPageSize())
|
|
|
+ );
|
|
|
+ List<Hospital580PrescriptionScrmEntity> orderRecords = page.getRecords();
|
|
|
+ // 构建返回结果
|
|
|
+ List<PrescriptionListRes> result = orderRecords.stream()
|
|
|
+ .map(order -> {
|
|
|
+ return PrescriptionListRes.builder()
|
|
|
+ .pid(order.getPid())
|
|
|
+ .orderId(order.getPreId())
|
|
|
+ .createdTime(order.getCreatedTime())
|
|
|
+ .createTime(order.getCreatedTime())
|
|
|
+ .tags(order.getTags())
|
|
|
+ .userFamilyName(order.getUserFamilyName())
|
|
|
+ .userFamilyGender(order.getUserFamilyGender())
|
|
|
+ .userFamilyAge(order.getUserFamilyAge())
|
|
|
+ .prescriptionStatus(order.getPrescriptionStatus())
|
|
|
+ .doctorName(order.getDoctorName())
|
|
|
+ .build();
|
|
|
+ })
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ return PageResponse.of(result, Math.toIntExact(page.getTotal()), pageRequest.getPageSize(), pageRequest.getPageNum());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result<PrescriptionDetailRes> prescriptionDetail(String userId, Long preId) {
|
|
|
+ Hospital580PrescriptionScrmEntity byId = orderScrmService.getById(preId);
|
|
|
+ return Result.success(BeanUtil.toBean(byId, PrescriptionDetailRes.class));
|
|
|
}
|
|
|
|
|
|
- private R processResult(Result580 result580) {
|
|
|
+ private Result<String> processResult(Result580 result580) {
|
|
|
if (0 == result580.getErr()) {
|
|
|
- return R.ok().put("data", result580.getData());
|
|
|
+ return Result.success(result580.getData());
|
|
|
}
|
|
|
throw new RuntimeException(result580.getErrmsg());
|
|
|
}
|