|
@ -1,10 +1,16 @@
|
|
|
package com.yihu.wlyy.service.app.prescription;
|
|
|
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionPay;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.*;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionDispensaryCodeDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionLogDao;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
/**
|
|
|
* Created by chenweida on 2017/7/27.
|
|
@ -14,13 +20,57 @@ import org.springframework.stereotype.Service;
|
|
|
public class PrescriptionExpressageService {
|
|
|
@Autowired
|
|
|
private PrescriptionExpressageDao prescriptionExpressageDao;
|
|
|
@Autowired
|
|
|
private PrescriptionDispensaryCodeDao prescriptionDispensaryCodeDao;
|
|
|
@Autowired
|
|
|
private PrescriptionLogDao prescriptionLogDao;
|
|
|
@Autowired
|
|
|
private PrescriptionDao prescriptionDao;
|
|
|
|
|
|
/**
|
|
|
* 获取处方配送信息信息
|
|
|
* 获取处方配送信息信息
|
|
|
*
|
|
|
* @param prescriptionCode 处方code
|
|
|
* @return
|
|
|
*/
|
|
|
public PrescriptionExpressage findByPrescriptionCode(String prescriptionCode) {
|
|
|
return prescriptionExpressageDao.findByPrescriptionPay(prescriptionCode);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 确认配送成功
|
|
|
*
|
|
|
* @param code
|
|
|
*/
|
|
|
@Transactional
|
|
|
public Integer expressage(String code, String userCode) throws Exception {
|
|
|
//获取根据wlyy_prescription_dispensary_code的code处方编码
|
|
|
PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeDao.finByCode(code);
|
|
|
if (prescriptionDispensaryCode == null) {
|
|
|
PrescriptionLog prescriptionLog = new PrescriptionLog();
|
|
|
prescriptionLog.setCode(UUID.randomUUID().toString());
|
|
|
prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
|
|
|
prescriptionLog.setCreateTime(new Date());
|
|
|
prescriptionLog.setFlag(1);
|
|
|
prescriptionLog.setUserCode(userCode);
|
|
|
prescriptionLog.setUserType(2);
|
|
|
prescriptionLog.setType(42);
|
|
|
prescriptionLog.setRemark("配送失败,处方编码不存在");
|
|
|
prescriptionLogDao.save(prescriptionLog);
|
|
|
return -1;
|
|
|
}
|
|
|
//修改处方状态为完成
|
|
|
prescriptionDao.updateStatus(prescriptionDispensaryCode.getPrescriptionCode(),100);
|
|
|
//保存操作日志
|
|
|
PrescriptionLog prescriptionLog = new PrescriptionLog();
|
|
|
prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
|
|
|
prescriptionLog.setCode(UUID.randomUUID().toString());
|
|
|
prescriptionLog.setCreateTime(new Date());
|
|
|
prescriptionLog.setFlag(1);
|
|
|
prescriptionLog.setUserCode(userCode);
|
|
|
prescriptionLog.setUserType(2);
|
|
|
prescriptionLog.setType(100);
|
|
|
prescriptionLogDao.save(prescriptionLog);
|
|
|
return 1;
|
|
|
}
|
|
|
}
|