采购入库代码补全
This commit is contained in:
@@ -20,12 +20,12 @@ import com.openhis.common.constant.CommonConstants;
|
||||
import com.openhis.common.constant.PromptMsgConstant;
|
||||
import com.openhis.common.enums.SupplyCategory;
|
||||
import com.openhis.common.enums.SupplyType;
|
||||
import com.openhis.common.utils.HisPageUtils;
|
||||
import com.openhis.common.utils.HisQueryUtils;
|
||||
import com.openhis.web.inventorymanage.appservice.IPurchaseInventoryAppService;
|
||||
import com.openhis.web.inventorymanage.dto.InventoryReceiptDto;
|
||||
import com.openhis.web.inventorymanage.dto.InventoryReceiptPageDto;
|
||||
import com.openhis.web.inventorymanage.dto.InventorySearchParam;
|
||||
import com.openhis.web.inventorymanage.mapper.PurchaseInventoryMapper;
|
||||
import com.openhis.workflow.domain.SupplyRequest;
|
||||
import com.openhis.workflow.mapper.SupplyRequestMapper;
|
||||
import com.openhis.workflow.service.ISupplyRequestService;
|
||||
@@ -42,6 +42,9 @@ public class PurchaseInventoryAppServiceImpl implements IPurchaseInventoryAppSer
|
||||
@Autowired
|
||||
private SupplyRequestMapper supplyRequestMapper;
|
||||
|
||||
@Autowired
|
||||
private PurchaseInventoryMapper purchaseInventoryMapper;
|
||||
|
||||
@Autowired
|
||||
private ISupplyRequestService supplyRequestService;
|
||||
|
||||
@@ -59,7 +62,6 @@ public class PurchaseInventoryAppServiceImpl implements IPurchaseInventoryAppSer
|
||||
public R<?> getPage(InventorySearchParam inventorySearchParam, Integer pageNo, Integer pageSize, String searchKey,
|
||||
HttpServletRequest request) {
|
||||
|
||||
// 按照单据号groupBy
|
||||
// 设置模糊查询的字段名
|
||||
HashSet<String> searchFields = new HashSet<>();
|
||||
searchFields.add(CommonConstants.FieldName.BusNo);
|
||||
@@ -68,8 +70,8 @@ public class PurchaseInventoryAppServiceImpl implements IPurchaseInventoryAppSer
|
||||
QueryWrapper<SupplyRequest> queryWrapper =
|
||||
HisQueryUtils.buildQueryWrapper(inventorySearchParam, searchKey, searchFields, request);
|
||||
// 查询入库单据分页列表
|
||||
Page<InventoryReceiptPageDto> inventoryReceiptPage =
|
||||
HisPageUtils.selectPage(supplyRequestMapper, queryWrapper, pageNo, pageSize, InventoryReceiptPageDto.class);
|
||||
Page<InventoryReceiptPageDto> inventoryReceiptPage = purchaseInventoryMapper.selectInventoryReceiptPage(
|
||||
new Page<>(pageNo, pageSize), queryWrapper, SupplyType.PURCHASE_INVENTORY.getValue());
|
||||
return R.ok(inventoryReceiptPage);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import com.openhis.web.inventorymanage.appservice.IReceiptApprovalAppService;
|
||||
import com.openhis.web.inventorymanage.assembler.InventoryManageAssembler;
|
||||
import com.openhis.web.inventorymanage.dto.ItemChargeDetailDto;
|
||||
import com.openhis.web.inventorymanage.dto.SupplyItemDetailDto;
|
||||
import com.openhis.web.inventorymanage.mapper.InventoryManageMapper;
|
||||
import com.openhis.web.inventorymanage.mapper.ReceiptApprovalMapper;
|
||||
import com.openhis.workflow.domain.InventoryItem;
|
||||
import com.openhis.workflow.domain.SupplyDelivery;
|
||||
import com.openhis.workflow.domain.SupplyRequest;
|
||||
@@ -62,7 +62,7 @@ public class ReceiptApprovalAppServiceImpl implements IReceiptApprovalAppService
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
@Autowired
|
||||
private InventoryManageMapper inventoryManageMapper;
|
||||
private ReceiptApprovalMapper receiptApprovalMapper;
|
||||
|
||||
/**
|
||||
* 校验单据是否正确
|
||||
@@ -97,9 +97,9 @@ public class ReceiptApprovalAppServiceImpl implements IReceiptApprovalAppService
|
||||
List<SupplyItemDetailDto> supplyItemDetailList;
|
||||
// 判断供应项是药品还是耗材
|
||||
if (CommonConstants.TableName.MED_MEDICATION_DEFINITION.equals(itemTable)) {
|
||||
supplyItemDetailList = inventoryManageMapper.selectSupplyMedDetail(busNo, EventStatus.COMPLETED.getValue());
|
||||
supplyItemDetailList = receiptApprovalMapper.selectSupplyMedDetail(busNo, EventStatus.COMPLETED.getValue());
|
||||
} else if (CommonConstants.TableName.ADM_DEVICE.equals(itemTable)) {
|
||||
supplyItemDetailList = inventoryManageMapper.selectSupplyDevDetail(busNo, EventStatus.COMPLETED.getValue());
|
||||
supplyItemDetailList = receiptApprovalMapper.selectSupplyDevDetail(busNo, EventStatus.COMPLETED.getValue());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class ReceiptApprovalAppServiceImpl implements IReceiptApprovalAppService
|
||||
public List<ItemChargeDetailDto> getItemChargeDetail(List<Long> itemIdList) {
|
||||
// todo:未来会移到charge相关的service中
|
||||
if (!itemIdList.isEmpty()) {
|
||||
return inventoryManageMapper.selectChargeDetail(itemIdList);
|
||||
return receiptApprovalMapper.selectChargeDetail(itemIdList);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -169,13 +169,11 @@ public class ReceiptApprovalAppServiceImpl implements IReceiptApprovalAppService
|
||||
if (!supplyItemDetailList.isEmpty()) {
|
||||
// 将供应项目的详细信息装配为库存项目和采购账单
|
||||
Pair<List<ChargeItem>, List<InventoryItem>> listPair =
|
||||
InventoryManageAssembler.assembleChargeAndInventory(supplyItemDetailList, now);
|
||||
if (listPair != null) {
|
||||
// 创建已结算的采购财务流水
|
||||
chargeItemService.createBilledPurchaseCharge(listPair.getLeft());
|
||||
// 入库
|
||||
inventoryItemService.stockIn(listPair.getRight());
|
||||
}
|
||||
InventoryManageAssembler.assembleChargeAndInventory(supplyItemDetailList, now, loginUser);
|
||||
// 创建已结算的采购财务流水
|
||||
chargeItemService.createBilledPurchaseCharge(listPair.getLeft());
|
||||
// 入库
|
||||
inventoryItemService.stockIn(listPair.getRight());
|
||||
}
|
||||
return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, null));
|
||||
}
|
||||
|
||||
@@ -3,12 +3,17 @@
|
||||
*/
|
||||
package com.openhis.web.inventorymanage.assembler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.core.common.core.domain.model.LoginUser;
|
||||
import com.openhis.administration.domain.ChargeItem;
|
||||
import com.openhis.common.constant.CommonConstants;
|
||||
import com.openhis.common.enums.ChargeItemContext;
|
||||
import com.openhis.common.enums.ChargeItemStatus;
|
||||
import com.openhis.web.inventorymanage.dto.SupplyItemDetailDto;
|
||||
import com.openhis.workflow.domain.InventoryItem;
|
||||
|
||||
@@ -25,10 +30,92 @@ public class InventoryManageAssembler {
|
||||
*
|
||||
* @param supplyItemDetailList 供应项目的详细信息
|
||||
* @param now 当前时间
|
||||
* @param loginUser 登陆者信息
|
||||
* @return 库存项目和采购账单
|
||||
*/
|
||||
public static Pair<List<ChargeItem>, List<InventoryItem>>
|
||||
assembleChargeAndInventory(List<SupplyItemDetailDto> supplyItemDetailList, Date now) {
|
||||
return null;
|
||||
assembleChargeAndInventory(List<SupplyItemDetailDto> supplyItemDetailList, Date now, LoginUser loginUser) {
|
||||
|
||||
List<ChargeItem> chargeItemList = new ArrayList<>();
|
||||
List<InventoryItem> inventoryItemList = new ArrayList<>();
|
||||
for (SupplyItemDetailDto supplyItemDetailDto : supplyItemDetailList) {
|
||||
|
||||
ChargeItem chargeItem = new ChargeItem();
|
||||
chargeItem
|
||||
// 收费项所在表:供应物品所在表
|
||||
.setProductTable(supplyItemDetailDto.getItemTable())
|
||||
// 收费项id:供应物品id
|
||||
.setProductId(supplyItemDetailDto.getItemId())
|
||||
// 物品数量
|
||||
.setQuantityValue(supplyItemDetailDto.getItemQuantity().longValue())
|
||||
// 物品单位
|
||||
.setQuantityUnit(supplyItemDetailDto.getItemUnit())
|
||||
// 原价
|
||||
.setBaseAmount(supplyItemDetailDto.getBaseAmount())
|
||||
// 总价
|
||||
.setTotalPrice(supplyItemDetailDto.getTotalPrice())
|
||||
// 单价
|
||||
.setUnitPrice(supplyItemDetailDto.getPrice())
|
||||
// 价格定义id
|
||||
.setDefinitionId(supplyItemDetailDto.getDefinitionId())
|
||||
// 价格定义子表id
|
||||
.setDefDetailId(supplyItemDetailDto.getDefDetailId())
|
||||
// 执行人:审批人
|
||||
.setPerformerId(supplyItemDetailDto.getApproverId())
|
||||
// 执行科室:发放目的仓库
|
||||
.setPerformingOrgId(supplyItemDetailDto.getPurposeLocationId())
|
||||
// 收费来源id:供应服务id
|
||||
.setServiceId(supplyItemDetailDto.getServiceId())
|
||||
// 收费来源表:发放请求
|
||||
.setServiceTable(CommonConstants.TableName.WOR_SUPPLY_REQUEST)
|
||||
// 收费状态:已结算
|
||||
.setStatusEnum(ChargeItemStatus.BILLED.getValue())
|
||||
// 收费类型:采购
|
||||
.setContextEnum(ChargeItemContext.PRESCRIPTION.getValue())
|
||||
// 发生时间
|
||||
.setOccurrenceTime(now)
|
||||
// 开立人
|
||||
.setEntererId(loginUser.getUserId())
|
||||
// 开立时间
|
||||
.setEnteredDate(now);
|
||||
|
||||
InventoryItem inventoryItem = new InventoryItem();
|
||||
inventoryItem.setItemId(supplyItemDetailDto.getItemId())
|
||||
// 入库项目所在表
|
||||
.setItemTable(supplyItemDetailDto.getItemTable())
|
||||
// 入库项目
|
||||
.setItemId(supplyItemDetailDto.getItemId())
|
||||
// 入库项目类型
|
||||
.setCategoryEnum(Integer.valueOf(supplyItemDetailDto.getItemCategory()))
|
||||
// 批号
|
||||
.setLotNumber(supplyItemDetailDto.getLotNumber())
|
||||
// 追溯码
|
||||
.setTraceNo(supplyItemDetailDto.getTraceNo())
|
||||
// 供应商
|
||||
.setSupplierId(supplyItemDetailDto.getSupplierId())
|
||||
// 仓库
|
||||
.setLocationId(supplyItemDetailDto.getPurposeLocationId())
|
||||
// 库位
|
||||
.setLocationStoreId(supplyItemDetailDto.getPurposeLocationStoreId())
|
||||
// 过期日期
|
||||
.setExpirationDate(supplyItemDetailDto.getEndTime())
|
||||
// 生产日期
|
||||
.setProductionDate(supplyItemDetailDto.getStartTime())
|
||||
// 项目名
|
||||
.setName(supplyItemDetailDto.getName())
|
||||
// 拼音码
|
||||
.setPyStr(supplyItemDetailDto.getPyStr())
|
||||
// 五笔码
|
||||
.setWbStr(supplyItemDetailDto.getWbStr())
|
||||
// 包装单位
|
||||
.setBaseUnitCode(supplyItemDetailDto.getUnitCode())
|
||||
// 最小单位
|
||||
.setMinUnitCode(supplyItemDetailDto.getMinUnitCode());
|
||||
|
||||
chargeItemList.add(chargeItem);
|
||||
inventoryItemList.add(inventoryItem);
|
||||
}
|
||||
|
||||
return Pair.of(chargeItemList, inventoryItemList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,21 +34,12 @@ public class InventoryReceiptPageDto implements Serializable {
|
||||
/** 单据号 */
|
||||
private String busNo;
|
||||
|
||||
/** 类型 */
|
||||
private Integer typeEnum;
|
||||
|
||||
/** 状态 */
|
||||
private Integer statusEnum;
|
||||
|
||||
/** 分类 */
|
||||
private Integer categoryEnum;
|
||||
|
||||
/** 供应商 */
|
||||
private Long supplierId;
|
||||
|
||||
/** 源仓库 */
|
||||
private Long sourceLocationId;
|
||||
|
||||
/** 目的仓库 */
|
||||
private Long purposeLocationId;
|
||||
|
||||
|
||||
@@ -7,6 +7,10 @@ import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
|
||||
import liquibase.pro.packaged.S;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@@ -22,6 +26,10 @@ public class SupplyItemDetailDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long supplyId;
|
||||
|
||||
/** 项目 */
|
||||
private String itemTable;
|
||||
|
||||
@@ -93,4 +101,7 @@ public class SupplyItemDetailDto implements Serializable {
|
||||
|
||||
/** 定价子表主键 */
|
||||
private Long defDetailId;
|
||||
|
||||
/** 项目类型 */
|
||||
private String itemCategory;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright ©2023 CJB-CNIT Team. All rights reserved
|
||||
*/
|
||||
package com.openhis.web.inventorymanage.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.openhis.web.inventorymanage.dto.InventoryReceiptPageDto;
|
||||
import com.openhis.workflow.domain.SupplyRequest;
|
||||
|
||||
/**
|
||||
* 采购入库查询用 mapper
|
||||
*
|
||||
* @author zwh
|
||||
* @date 2025-03-10
|
||||
*/
|
||||
@Repository
|
||||
public interface PurchaseInventoryMapper {
|
||||
|
||||
/**
|
||||
* 查询入库单据分页列表
|
||||
*
|
||||
* @param page 分页
|
||||
* @param queryWrapper 查询条件
|
||||
* @param purchaseInventory 单据类型:采购入库
|
||||
* @return 入库单据分页列表
|
||||
*/
|
||||
Page<InventoryReceiptPageDto> selectInventoryReceiptPage(@Param("page") Page<InventoryReceiptPageDto> page,
|
||||
@Param(Constants.WRAPPER) QueryWrapper<SupplyRequest> queryWrapper,
|
||||
@Param("purchaseInventory") Integer purchaseInventory);
|
||||
}
|
||||
@@ -14,13 +14,13 @@ import com.openhis.web.inventorymanage.dto.SupplyItemDetailDto;
|
||||
import com.openhis.workflow.domain.SupplyRequest;
|
||||
|
||||
/**
|
||||
* 库存管理查询用 mapper
|
||||
* 单据审批查询用 mapper
|
||||
*
|
||||
* @author zwh
|
||||
* @date 2025-02-25
|
||||
*/
|
||||
@Repository
|
||||
public interface InventoryManageMapper extends BaseMapper<SupplyRequest> {
|
||||
public interface ReceiptApprovalMapper extends BaseMapper<SupplyRequest> {
|
||||
|
||||
/**
|
||||
* 获取药品供应单据详细信息
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.openhis.web.inventorymanage.mapper.PurchaseInventoryMapper">
|
||||
|
||||
<select id="selectInventoryReceiptPage"
|
||||
resultType="com.openhis.web.inventorymanage.dto.InventoryReceiptPageDto">
|
||||
SELECT id,
|
||||
bus_no,
|
||||
status_enum,
|
||||
supplier_id,
|
||||
purpose_location_id,
|
||||
approver_id,
|
||||
approval_time,
|
||||
applicant_id,
|
||||
apply_time,
|
||||
purpose_location_id
|
||||
FROM wor_supply_request
|
||||
WHERE type_enum = #{purchaseInventory}
|
||||
GROUP BY id,
|
||||
bus_no,
|
||||
status_enum,
|
||||
supplier_id,
|
||||
purpose_location_id,
|
||||
approver_id,
|
||||
approval_time,
|
||||
applicant_id,
|
||||
apply_time,
|
||||
purpose_location_id
|
||||
ORDER BY bus_no desc
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,9 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.openhis.web.inventorymanage.mapper.InventoryManageMapper">
|
||||
<mapper namespace="com.openhis.web.inventorymanage.mapper.ReceiptApprovalMapper">
|
||||
|
||||
<select id="selectSupplyMedDetail" resultType="com.openhis.web.inventorymanage.dto.SupplyItemDetailDto">
|
||||
SELECT T1.item_table,
|
||||
SELECT T1.id AS supply_id
|
||||
T1.item_table,
|
||||
T1.item_id,
|
||||
T1.item_quantity,
|
||||
T1.unit_code AS item_unit,
|
||||
@@ -26,9 +27,10 @@
|
||||
T2.wb_str,
|
||||
T2.unit_code,
|
||||
T2.min_unit_code,
|
||||
T2.category_code AS item_category,
|
||||
T3.id AS definition_id,
|
||||
T4.amount AS base_amount,
|
||||
T4.id AS applicability_id
|
||||
T4.id AS def_detail_id
|
||||
FROM wor_supply_request AS T1
|
||||
LEFT JOIN wor_supply_delivery AS T5
|
||||
ON T1.id = T5.request_id
|
||||
Reference in New Issue
Block a user