|
|
@@ -33,6 +33,8 @@ import thyyxxk.webserver.utils.*;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
+import java.util.function.Consumer;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -884,20 +886,24 @@ public class XiangMuLuRuService {
|
|
|
|
|
|
public ResultVo<List<DrugReturnForm>> getNoMedicineReturnOrderGenerated(String startDate, String endDate, String groupNo) {
|
|
|
UserInfo us = redisLikeService.getUserInfoByToken();
|
|
|
- return ResultVoUtil.success(groupingValues(dao.selectNoMedicineReturnOrderGenerated(startDate, endDate, us.getDeptCode(), groupNo)));
|
|
|
+ return ResultVoUtil.success(groupingValues(dao.selectNoMedicineReturnOrderGenerated(startDate, endDate, us.getDeptCode(), groupNo), null));
|
|
|
}
|
|
|
|
|
|
- public List<DrugReturnForm> groupingValues(List<DrugReturnForm> list) {
|
|
|
+ public List<DrugReturnForm> groupingValues(List<DrugReturnForm> list, Consumer<DrugReturnForm> consumer) {
|
|
|
if (ListUtil.isBlank(list)) {
|
|
|
return list;
|
|
|
}
|
|
|
Map<String, DrugReturnForm> map = new HashMap<>(list.size());
|
|
|
list.forEach(item -> {
|
|
|
+ if (consumer != null) {
|
|
|
+ consumer.accept(item);
|
|
|
+ }
|
|
|
if (map.containsKey(item.getChargeCode())) {
|
|
|
DrugReturnForm temp = map.get(item.getChargeCode());
|
|
|
temp.setAmount(temp.getAmount().add(item.getAmount()));
|
|
|
- temp.setRetprice(temp.getRetprice().add(item.getRetprice()));
|
|
|
+ temp.setRetprice(temp.getRetprice().add(item.getRetprice().multiply(item.getAmount().abs())));
|
|
|
} else {
|
|
|
+ item.setRetprice(item.getRetprice().multiply(item.getAmount().abs()));
|
|
|
map.put(item.getChargeCode(), item);
|
|
|
}
|
|
|
});
|
|
|
@@ -912,11 +918,11 @@ public class XiangMuLuRuService {
|
|
|
* @param groupNo 药房
|
|
|
* @return 返回提示
|
|
|
*/
|
|
|
- public ResultVo<Integer> generateMedicationList(String startDate, String endDate, String groupNo) {
|
|
|
+ public ResultVo<JSONObject> generateMedicationList(String startDate, String endDate, String groupNo, Integer refundReason) {
|
|
|
UserInfo us = redisLikeService.getUserInfoByToken();
|
|
|
Integer pageNo = publicServer.getTheDrugListNo();
|
|
|
- getThis().generateMedicationListFunc(startDate, endDate, groupNo, pageNo, us.getDeptCode());
|
|
|
- return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "药单生成成功。", pageNo);
|
|
|
+ getThis().generateMedicationListFunc(startDate, endDate, groupNo, pageNo, us.getDeptCode(), refundReason);
|
|
|
+ return getAPrescriptionByPageNo(pageNo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -929,12 +935,12 @@ public class XiangMuLuRuService {
|
|
|
* @param dept 科室
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void generateMedicationListFunc(String startDate, String endDate, String groupNo, Integer pageNo, String dept) {
|
|
|
+ public void generateMedicationListFunc(String startDate, String endDate, String groupNo, Integer pageNo, String dept, Integer refundReason) {
|
|
|
int count = dao.generateMedicationList(startDate, endDate, dept, groupNo, pageNo);
|
|
|
if (count == 0) {
|
|
|
throw new BizException(ExceptionEnum.LOGICAL_ERROR, "取数为空无法生成药单。");
|
|
|
}
|
|
|
- dao.drugReturnForm(pageNo, dept, TokenUtil.getTokenUserId(), groupNo);
|
|
|
+ dao.drugReturnForm(pageNo, dept, TokenUtil.getTokenUserId(), groupNo, refundReason);
|
|
|
log.info("退药药单生成成功操作人:{},药单号:{}", TokenUtil.getTokenUserId(), pageNo);
|
|
|
}
|
|
|
|
|
|
@@ -956,8 +962,21 @@ public class XiangMuLuRuService {
|
|
|
* @param pageNo
|
|
|
* @return
|
|
|
*/
|
|
|
- public ResultVo<List<DrugReturnForm>> getAPrescriptionByPageNo(Integer pageNo) {
|
|
|
- return ResultVoUtil.success(groupingValues(dao.getAPrescriptionByPageNo(pageNo)));
|
|
|
+ public ResultVo<JSONObject> getAPrescriptionByPageNo(Integer pageNo) {
|
|
|
+ JSONObject js = new JSONObject();
|
|
|
+ // 总金额
|
|
|
+ AtomicReference<BigDecimal> totalFee = new AtomicReference<>(new BigDecimal("0"));
|
|
|
+ // 计算数据
|
|
|
+ List<DrugReturnForm> list = groupingValues(dao.getAPrescriptionByPageNo(pageNo), (item) -> {
|
|
|
+ BigDecimal amount = item.getAmount().abs();
|
|
|
+ totalFee.set(totalFee.get().add(amount.multiply(item.getRetprice())));
|
|
|
+ });
|
|
|
+
|
|
|
+ js.put("totalFee", totalFee.get().negate());
|
|
|
+ js.put("refundReason", dao.selectRefundReasonByPageNo(pageNo));
|
|
|
+ js.put("data", list);
|
|
|
+ js.put("pageNo", pageNo);
|
|
|
+ return ResultVoUtil.success(js);
|
|
|
}
|
|
|
|
|
|
}
|