|
@@ -6,14 +6,17 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.collections4.ListUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.constants.GetDateFormat;
|
|
|
+import thyyxxk.webserver.dao.his.inpatient.XiangMuLuRuDao;
|
|
|
import thyyxxk.webserver.dao.his.zhuyuanyisheng.CaoYaoYiZhuDao;
|
|
|
import thyyxxk.webserver.dao.his.zhuyuanyisheng.YiZhuLuRuDao;
|
|
|
import thyyxxk.webserver.entity.ResultVo;
|
|
|
import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
|
|
|
+import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;
|
|
|
import thyyxxk.webserver.entity.zhuyuanyisheng.caoyaoyizhu.CaoYaoChaXunTiaoJian;
|
|
|
import thyyxxk.webserver.entity.zhuyuanyisheng.caoyaoyizhu.YzActOrderCy;
|
|
|
import thyyxxk.webserver.entity.zhuyuanyisheng.caoyaoyizhu.YzActOrderCyDetail;
|
|
@@ -43,12 +46,14 @@ public class CaoYaoYiZhuService {
|
|
|
private final PublicServer publicServer;
|
|
|
private final YiZhuLuRuDao yiZhuLuRuDao;
|
|
|
private final YiZhuLuRuServer yiZhuLuRuServer;
|
|
|
+ private final XiangMuLuRuDao xiangMuLuRuDao;
|
|
|
|
|
|
- public CaoYaoYiZhuService(CaoYaoYiZhuDao dao, PublicServer publicServer, YiZhuLuRuDao yiZhuLuRuDao, YiZhuLuRuServer yiZhuLuRuServer) {
|
|
|
+ public CaoYaoYiZhuService(CaoYaoYiZhuDao dao, PublicServer publicServer, YiZhuLuRuDao yiZhuLuRuDao, YiZhuLuRuServer yiZhuLuRuServer, XiangMuLuRuDao xiangMuLuRuDao) {
|
|
|
this.dao = dao;
|
|
|
this.publicServer = publicServer;
|
|
|
this.yiZhuLuRuDao = yiZhuLuRuDao;
|
|
|
this.yiZhuLuRuServer = yiZhuLuRuServer;
|
|
|
+ this.xiangMuLuRuDao = xiangMuLuRuDao;
|
|
|
}
|
|
|
|
|
|
private CaoYaoYiZhuService getThis() {
|
|
@@ -241,15 +246,15 @@ public class CaoYaoYiZhuService {
|
|
|
*/
|
|
|
public ResultVo<String> shanChuMuBan(String name, String deptCode) {
|
|
|
YzOrderPatternCy mb = dao.caoYaoMuBanXiangQing(name);
|
|
|
- List<Integer> rolse = publicServer.getRoleCode().getData();
|
|
|
// 如果有这个权限直接删除
|
|
|
- if (publicServer.noNeedRule(rolse, YiZhuPublicService.MU_BAN_BIAN_JI_QUAN_XIAN)) {
|
|
|
+
|
|
|
+ if (publicServer.needRule(YiZhuPublicService.MU_BAN_BIAN_JI_QUAN_XIAN)) {
|
|
|
// 本人创建的也可以直接删除
|
|
|
if (mb.getCreateId().equals(TokenUtil.getTokenUserId())) {
|
|
|
return shanChuCaoYaoMuBan(name);
|
|
|
}
|
|
|
// 科主任 可以删除自己科室的模板
|
|
|
- if (publicServer.needRule(rolse, YiZhuPublicService.KE_ZHU_REN_BIAN_MA)) {
|
|
|
+ if (publicServer.needRule(YiZhuPublicService.KE_ZHU_REN_BIAN_MA)) {
|
|
|
if (mb.getDeptCode().trim().equals(deptCode)) {
|
|
|
return shanChuCaoYaoMuBan(name);
|
|
|
}
|
|
@@ -265,19 +270,45 @@ public class CaoYaoYiZhuService {
|
|
|
return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public ResultVo<String> shanChuCaoYao(String patNo, Integer times, BigDecimal orderNo) {
|
|
|
YzActOrderCy cy = dao.caoYaoXinXi(patNo, times, orderNo);
|
|
|
if (cy == null) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有查询到原来的信息。");
|
|
|
}
|
|
|
- if (!"2".equals(cy.getStatusFlag().trim())) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该草药无法删除。");
|
|
|
- }
|
|
|
-
|
|
|
log.info("删除草药==》操作人:{},数据:{}", TokenUtil.getTokenUserId(), JSON.toJSONStringWithDateFormat(cy, GetDateFormat.DATE_TIME));
|
|
|
dao.genXingCaoYaoShanChuBiaoZhi(patNo, times, orderNo);
|
|
|
dao.shanChuYiZhu(orderNo);
|
|
|
+ feeRefunds(cy);
|
|
|
return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 草药退费
|
|
|
+ *
|
|
|
+ * @param cy 草药信息
|
|
|
+ */
|
|
|
+ private void feeRefunds(YzActOrderCy cy) {
|
|
|
+ List<ZyDetailCharge> cyList = dao.caoYaoFeiYong(cy);
|
|
|
+ int maxDetailSn = publicServer.getMaxDetailSn(cy.getInpatientNo(), cy.getAdmissTimes());
|
|
|
+ String userCode = TokenUtil.getTokenUserId();
|
|
|
+ if (ListUtil.notBlank(cyList)) {
|
|
|
+ List<ZyDetailCharge> refundArray = new ArrayList<>(cyList.size());
|
|
|
+ for (ZyDetailCharge item : cyList) {
|
|
|
+ item.setChargeFee(item.getChargeFee().negate());
|
|
|
+ item.setChargeAmount(item.getChargeAmount().negate());
|
|
|
+ item.setOpIdCode(userCode);
|
|
|
+ item.setOriDetailSn(item.getDetailSn());
|
|
|
+ // 设置 流水号
|
|
|
+ item.setDetailSn(maxDetailSn += 1);
|
|
|
+ item.setOrderNo(new BigDecimal(0));
|
|
|
+ item.setNewOrderNo(new BigDecimal(0));
|
|
|
+ refundArray.add(item);
|
|
|
+ }
|
|
|
+ List<List<ZyDetailCharge>> fenGe = ListUtils.partition(refundArray, 20);
|
|
|
+ fenGe.forEach(xiangMuLuRuDao::xiangMuTuiFei);
|
|
|
+ dao.modifyTheExpenseFlag(cy);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|