|
|
@@ -163,13 +163,27 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
|
|
|
public List<FsPrescribeListDVO> selectFsPrescribeListDVO(FsPrescribeListDParam param) {
|
|
|
List<FsPrescribeListDVO> list=fsPrescribeMapper.selectFsPrescribeListDVO(param);
|
|
|
for(FsPrescribeListDVO vo:list){
|
|
|
+ fillPrescribeListAuditDisplay(vo);
|
|
|
FsPrescribeDrug map=new FsPrescribeDrug();
|
|
|
map.setPrescribeId(vo.getPrescribeId());
|
|
|
vo.setDrugs(fsPrescribeDrugMapper.selectFsPrescribeDrugList(map));
|
|
|
}
|
|
|
return list;
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
+ private void fillPrescribeListAuditDisplay(FsPrescribeListDVO vo) {
|
|
|
+ Integer prescribeStatus = vo.getStatus() == null ? 0 : vo.getStatus();
|
|
|
+ // DB status: 0待审核/1审核通过/2审核拒绝 → 前端约定: 1待审核/2审核通过/3审核不通过
|
|
|
+ vo.setAuditStatus(prescribeStatus + 1);
|
|
|
+ if (prescribeStatus == 0) {
|
|
|
+ vo.setAuditStatusName("待审核");
|
|
|
+ } else if (prescribeStatus == 1) {
|
|
|
+ vo.setAuditStatusName("审核通过");
|
|
|
+ } else if (prescribeStatus == 2) {
|
|
|
+ vo.setAuditStatusName("审核拒绝");
|
|
|
+ } else {
|
|
|
+ vo.setAuditStatusName("未知");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -903,6 +917,9 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
|
|
|
List<FsPrescribe> FsPrescribes=fsPrescribeDrugMapper.selectFsPrescribeNoAudit();
|
|
|
for (FsPrescribe fsPrescribe : FsPrescribes) {
|
|
|
Long id = doctorMapper.selectFsDoctorType2Ids(fsPrescribe.getPrescribeType());
|
|
|
+ if (id == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
FsPrescribeAuditParam param=new FsPrescribeAuditParam();
|
|
|
param.setDoctorId(id);
|
|
|
param.setStatus(1);
|
|
|
@@ -914,9 +931,52 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public R audit(FsPrescribeAuditParam param){
|
|
|
+ if (param.getPrescribeId() == null) {
|
|
|
+ return R.error("处方ID不能为空");
|
|
|
+ }
|
|
|
+ if (param.getStatus() == null) {
|
|
|
+ return R.error("审核状态不能为空");
|
|
|
+ }
|
|
|
+ if (!Integer.valueOf(1).equals(param.getStatus()) && !Integer.valueOf(2).equals(param.getStatus())) {
|
|
|
+ return R.error("审核状态不正确");
|
|
|
+ }
|
|
|
FsPrescribe prescribe=this.selectFsPrescribeByPrescribeId(param.getPrescribeId());
|
|
|
- if(prescribe.getStatus()!=0){
|
|
|
- return R.error("非法操作");
|
|
|
+ if (prescribe == null) {
|
|
|
+ return R.error("处方不存在");
|
|
|
+ }
|
|
|
+ Integer prescribeStatus = prescribe.getStatus() == null ? 0 : prescribe.getStatus();
|
|
|
+ if (Integer.valueOf(1).equals(param.getStatus())) {
|
|
|
+ if (prescribeStatus == 1) {
|
|
|
+ if (prescribe.getStoreOrderId() != null) {
|
|
|
+ return R.error("该处方已审核通过");
|
|
|
+ }
|
|
|
+ R createResult = storeOrderService.createOrder(prescribe.getPrescribeId());
|
|
|
+ if (!isSuccess(createResult)) {
|
|
|
+ return R.error(getResultMsg(createResult, "创建订单失败"));
|
|
|
+ }
|
|
|
+ sendPrescribeAuditMsg(this.selectFsPrescribeByPrescribeId(param.getPrescribeId()));
|
|
|
+ return R.ok("处方已审核,订单已补建");
|
|
|
+ }
|
|
|
+ if (prescribeStatus == 2) {
|
|
|
+ return R.error("该处方已审核拒绝,无法通过");
|
|
|
+ }
|
|
|
+ if (prescribeStatus != 0) {
|
|
|
+ return R.error("当前处方状态不允许审核");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (prescribeStatus == 1) {
|
|
|
+ return R.error("该处方已审核通过,无法拒绝");
|
|
|
+ }
|
|
|
+ if (prescribeStatus == 2) {
|
|
|
+ return R.error("该处方已审核拒绝");
|
|
|
+ }
|
|
|
+ if (prescribeStatus != 0) {
|
|
|
+ return R.error("当前处方状态不允许审核");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ FsDoctor doctor=doctorService.selectFsDoctorByDoctorId(param.getDoctorId());
|
|
|
+ if (doctor == null) {
|
|
|
+ return R.error("审核医生不存在");
|
|
|
}
|
|
|
FsPrescribe map=new FsPrescribe();
|
|
|
map.setPrescribeId(param.getPrescribeId());
|
|
|
@@ -924,39 +984,57 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
|
|
|
map.setStatus(param.getStatus());
|
|
|
map.setAuditReason(param.getAuditReason());
|
|
|
map.setAuditTime(new Date());
|
|
|
- FsDoctor doctor=doctorService.selectFsDoctorByDoctorId(map.getDrugDoctorId());
|
|
|
if(StringUtils.isNotEmpty(doctor.getSignUrl())){
|
|
|
map.setDrugDoctorSignUrl(doctor.getSignUrl());
|
|
|
}
|
|
|
- if(param.getStatus().equals(1)){
|
|
|
- this.updateFsPrescribe(map);
|
|
|
- //写入订单
|
|
|
- storeOrderService.createOrder(prescribe.getPrescribeId());
|
|
|
- //发送信息
|
|
|
- String orderId=prescribe.getInquiryOrderId().toString();
|
|
|
- MsgDTO msgDTO=new MsgDTO();
|
|
|
- MsgCustomDTO customDTO=new MsgCustomDTO();
|
|
|
- FsInquiryOrder fsInquiryOrder = fsInquiryOrderMapper.selectFsInquiryOrderByOrderId(prescribe.getInquiryOrderId());
|
|
|
- customDTO.setType("inquiry");
|
|
|
- customDTO.setOrderId(orderId);
|
|
|
- customDTO.setImType(1);
|
|
|
- customDTO.setOrderType(fsInquiryOrder.getOrderType());
|
|
|
- msgDTO.setCloudCustomData(JSONUtil.toJsonStr(customDTO));
|
|
|
- msgDTO.setFrom_Account("D-"+prescribe.getDoctorId());
|
|
|
- msgDTO.setTo_Account("U-"+prescribe.getUserId());
|
|
|
- List<MsgDataDTO> msgs=new ArrayList<>();
|
|
|
- MsgDataDTO msg=new MsgDataDTO();
|
|
|
- String ext= JSONUtil.toJsonStr(prescribe);
|
|
|
-
|
|
|
- msg.setMsgContent(new MsgDataFormatDTO("prescribe",ext,orderId));
|
|
|
- msg.setMsgType("TIMCustomElem");//TIMCustomElem
|
|
|
- msgs.add(msg);
|
|
|
- msgDTO.setMsgBody(msgs);
|
|
|
- imService.sendMsg(msgDTO);
|
|
|
+ this.updateFsPrescribe(map);
|
|
|
+ if(Integer.valueOf(1).equals(param.getStatus())){
|
|
|
+ R createResult = storeOrderService.createOrder(prescribe.getPrescribeId());
|
|
|
+ if (!isSuccess(createResult)) {
|
|
|
+ throw new CustomException(getResultMsg(createResult, "创建订单失败"));
|
|
|
+ }
|
|
|
+ sendPrescribeAuditMsg(prescribe);
|
|
|
return R.ok();
|
|
|
}
|
|
|
return R.ok("操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isSuccess(R result) {
|
|
|
+ return result != null && Integer.valueOf(com.fs.common.constant.HttpStatus.SUCCESS).equals(result.get("code"));
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getResultMsg(R result, String defaultMsg) {
|
|
|
+ if (result == null || result.get("msg") == null) {
|
|
|
+ return defaultMsg;
|
|
|
+ }
|
|
|
+ return String.valueOf(result.get("msg"));
|
|
|
+ }
|
|
|
|
|
|
+ private void sendPrescribeAuditMsg(FsPrescribe prescribe) {
|
|
|
+ if (prescribe.getInquiryOrderId() == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String orderId = prescribe.getInquiryOrderId().toString();
|
|
|
+ MsgDTO msgDTO = new MsgDTO();
|
|
|
+ MsgCustomDTO customDTO = new MsgCustomDTO();
|
|
|
+ FsInquiryOrder fsInquiryOrder = fsInquiryOrderMapper.selectFsInquiryOrderByOrderId(prescribe.getInquiryOrderId());
|
|
|
+ customDTO.setType("inquiry");
|
|
|
+ customDTO.setOrderId(orderId);
|
|
|
+ customDTO.setImType(1);
|
|
|
+ if (fsInquiryOrder != null) {
|
|
|
+ customDTO.setOrderType(fsInquiryOrder.getOrderType());
|
|
|
+ }
|
|
|
+ msgDTO.setCloudCustomData(JSONUtil.toJsonStr(customDTO));
|
|
|
+ msgDTO.setFrom_Account("D-" + prescribe.getDoctorId());
|
|
|
+ msgDTO.setTo_Account("U-" + prescribe.getUserId());
|
|
|
+ List<MsgDataDTO> msgs = new ArrayList<>();
|
|
|
+ MsgDataDTO msg = new MsgDataDTO();
|
|
|
+ String ext = JSONUtil.toJsonStr(prescribe);
|
|
|
+ msg.setMsgContent(new MsgDataFormatDTO("prescribe", ext, orderId));
|
|
|
+ msg.setMsgType("TIMCustomElem");
|
|
|
+ msgs.add(msg);
|
|
|
+ msgDTO.setMsgBody(msgs);
|
|
|
+ imService.sendMsg(msgDTO);
|
|
|
}
|
|
|
|
|
|
public void penDrawString( Graphics2D pen,String value,int x,int y){
|