|
@@ -6,14 +6,17 @@ import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
import thyyxxk.webserver.config.exception.BizException;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.constants.ZyDepositFileStatusEnum;
|
|
|
-import thyyxxk.webserver.dao.his.medicaladvice.common.DictDataDao;
|
|
|
import thyyxxk.webserver.dao.his.inpatient.charge.CashierProcessDao;
|
|
|
import thyyxxk.webserver.dao.his.inpatient.charge.MzsfBillnoRecDao;
|
|
|
+import thyyxxk.webserver.dao.his.medicaladvice.common.DictDataDao;
|
|
|
import thyyxxk.webserver.entity.ResultVo;
|
|
|
import thyyxxk.webserver.entity.executeItem.NumberEnum;
|
|
|
import thyyxxk.webserver.entity.executeItem.ZyLedgerFile;
|
|
@@ -50,6 +53,8 @@ public class CashierProcessService {
|
|
|
private DictDataDao dictDataDao;
|
|
|
@Resource
|
|
|
private MzsfBillnoRecDao mzsfBillnoRecDao;
|
|
|
+ @Value("${appletThmzUrl}")
|
|
|
+ private String appletThmzUrl;
|
|
|
|
|
|
private static final String SETT_TYPE_JN = "交纳";
|
|
|
private static final String SETT_TYPE_TK = "退款";
|
|
@@ -122,6 +127,7 @@ public class CashierProcessService {
|
|
|
private void check(PatientParam param) {
|
|
|
AssertUtil.isnotBlank(param.getInpatientNo(), "住院号不能为空");
|
|
|
AssertUtil.isnotBlank(param.getAdmissTimes(), "住院次数不能为空");
|
|
|
+ BeanUtil.trimStrFields(param);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -359,6 +365,8 @@ public class CashierProcessService {
|
|
|
|
|
|
public ZyReceipt queryPrintZyFpData(PatientParam param) {
|
|
|
checkLedgerSn(param);
|
|
|
+ String fpVersion = Convert.toStr(queryFpVersion().getData());
|
|
|
+ String fpVersionStr = NumberEnum.ZERO.getCode().equals(fpVersion) ? "打印" : "上传";
|
|
|
ZyReceipt zyReceipt = dao.selectPrintZyFpData(param);
|
|
|
AssertUtil.isnotBlank(zyReceipt, "没可打印发票信息");
|
|
|
List<ZyLedgerFile> list = dao.selectZyLedgerFile(param);
|
|
@@ -372,7 +380,7 @@ public class CashierProcessService {
|
|
|
zyReceipt.setZyTs(diff == 0 ? 1 : diff + 1);
|
|
|
ZyLedgerFile zyLedgerFile = list.get(0);
|
|
|
if (zyLedgerFile.getCashDate() == null) {
|
|
|
- throw new BizException(ExceptionEnum.LOGICAL_ERROR, "未出纳处理,不能打印发票");
|
|
|
+ throw new BizException(ExceptionEnum.LOGICAL_ERROR, "未出纳处理,不能"+fpVersionStr+"发票");
|
|
|
}
|
|
|
zyReceipt.setYbTcZfJe(Convert.toBigDecimal(zyLedgerFile.getFundPaySumamt(), BigDecimal.ZERO).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
zyReceipt.setGrZhZfJe(Convert.toBigDecimal(zyLedgerFile.getAcctPay(), BigDecimal.ZERO).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
@@ -390,9 +398,36 @@ public class CashierProcessService {
|
|
|
}
|
|
|
zyReceipt.setYsHjJe(Convert.toBigDecimal(zyLedgerFile.getDeposit(), BigDecimal.ZERO));
|
|
|
BeanUtil.trimStrFields(zyReceipt);
|
|
|
+ if(NumberEnum.ONE.getCode().equals(fpVersion)){
|
|
|
+ ResultVo resultVo = uploadDzInvoice(param);
|
|
|
+ String typeFlagName = param.getTypeFlag() == 3 ? "上传电子发票" : "作废电子发票";
|
|
|
+ if(resultVo == null){
|
|
|
+ throw new BizException(typeFlagName+"失败");
|
|
|
+ }
|
|
|
+ if(resultVo.getCode() ==-1){
|
|
|
+ throw new BizException(resultVo.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
return zyReceipt;
|
|
|
}
|
|
|
|
|
|
+ public ResultVo uploadDzInvoice(PatientParam param){
|
|
|
+ Map<String, Object> paramMap = dealInvoiceParam(param);
|
|
|
+ paramMap.put("opId", TokenUtil.getInstance().getTokenUserId());
|
|
|
+ ResultVo response = new RestTemplate().postForObject(appletThmzUrl+"/uploadZyInvoice", paramMap, ResultVo.class);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ @NotNull
|
|
|
+ private Map<String, Object> dealInvoiceParam(PatientParam param) {
|
|
|
+ Map<String, Object> paramMap = new HashMap<>();
|
|
|
+ paramMap.put("patientId", param.getInpatientNo());
|
|
|
+ paramMap.put("times", param.getAdmissTimes());
|
|
|
+ paramMap.put("typeFlag", param.getTypeFlag());
|
|
|
+ paramMap.put("receiptNo", param.getLedgerSn());
|
|
|
+ return paramMap;
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public ResultVo<String> cashierDataTx(PatientParam param) {
|
|
|
check(param);
|
|
@@ -438,4 +473,21 @@ public class CashierProcessService {
|
|
|
check(param);
|
|
|
return ResultVoUtil.success(dao.selectMaxAndMinLedgerSn(param));
|
|
|
}
|
|
|
+
|
|
|
+ public ResultVo<Map<String, Object>> downDzInvoice(PatientParam param) {
|
|
|
+ Map<String, Object> paramMap = dealInvoiceParam(param);
|
|
|
+ ResultVo response = new RestTemplate().postForObject(appletThmzUrl+"/queryInvoiceFile", paramMap, ResultVo.class);
|
|
|
+ if(response == null ){
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_HTML_ERROR, "下载电子发票错误");
|
|
|
+ }
|
|
|
+ if(response.getCode() == -1 ){
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_HTML_ERROR, response.getMessage());
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success(ExceptionEnum.SUCCESS, (Map)response.getData());
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<String> queryFpVersion() {
|
|
|
+ String fpVersion = dictDataDao.getDictValueByDictName("3.5", "fp_version");
|
|
|
+ return ResultVoUtil.success(Convert.toStr(fpVersion,"0"));
|
|
|
+ }
|
|
|
}
|