新增接口简单demo 仅作示例
This commit is contained in:
@@ -1,17 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright ©2023 CJB-CNIT Team. All rights reserved
|
* Copyright ©2023 CJB-CNIT Team. All rights reserved
|
||||||
*/
|
*/
|
||||||
package com.openhis.web.inventoryManage.controller;
|
package com.openhis.web.InventoryManage.controller;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import com.openhis.workflow.service.ISupplyRequestService;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.core.common.core.domain.R;
|
||||||
|
import com.core.common.utils.bean.BeanUtils;
|
||||||
|
import com.openhis.administration.domain.ChargeItem;
|
||||||
|
import com.openhis.administration.service.IChargeItemService;
|
||||||
|
import com.openhis.web.InventoryManage.dto.SupplyRequestDto;
|
||||||
import com.openhis.web.inventoryManage.dto.SupplySearchParam;
|
import com.openhis.web.inventoryManage.dto.SupplySearchParam;
|
||||||
import com.openhis.workflow.domain.SupplyRequest;
|
import com.openhis.workflow.domain.SupplyRequest;
|
||||||
|
import com.openhis.workflow.service.ISupplyRequestService;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -30,6 +35,8 @@ public class PurchaseInventoryController {
|
|||||||
|
|
||||||
private final ISupplyRequestService supplyRequestService;
|
private final ISupplyRequestService supplyRequestService;
|
||||||
|
|
||||||
|
private final IChargeItemService chargeItemService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 入库单据分页列表
|
* 入库单据分页列表
|
||||||
*
|
*
|
||||||
@@ -45,7 +52,7 @@ public class PurchaseInventoryController {
|
|||||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) {
|
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) {
|
||||||
// 查询supply_request相关信息并返回分页列表
|
// 查询supply_request相关信息并返回分页列表
|
||||||
|
|
||||||
return supplyRequestService.page(new Page<>(pageNo,pageSize));
|
return supplyRequestService.page(new Page<>(pageNo, pageSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加入库单据之前需要
|
// 添加入库单据之前需要
|
||||||
@@ -57,14 +64,32 @@ public class PurchaseInventoryController {
|
|||||||
/**
|
/**
|
||||||
* 添加入库单据(生成供应请求)
|
* 添加入库单据(生成供应请求)
|
||||||
*
|
*
|
||||||
* @param supplyRequest 供应请求信息
|
* @param supplyRequestDto 供应请求信息
|
||||||
*/
|
*/
|
||||||
@PostMapping("/add-supply-request")
|
@PostMapping("/add-supply-request")
|
||||||
public void addSupplyRequest(@Validated @RequestBody SupplyRequest supplyRequest) {
|
public R<?> addSupplyRequest(@Validated @RequestBody SupplyRequestDto supplyRequestDto) {
|
||||||
// 生成待发送的入库单据supply_request
|
// 生成待发送的入库单据supply_request
|
||||||
// 生成收费项目charge_item
|
SupplyRequest supplyRequest = new SupplyRequest();
|
||||||
|
BeanUtils.copyProperties(supplyRequestDto, supplyRequest);
|
||||||
|
// 如果业务上不需要其它处理 直接调用service的保存方法
|
||||||
|
boolean saveSupplyRequestSuccess = supplyRequestService.save(supplyRequest);
|
||||||
|
|
||||||
// 如果采购单价被修改了,需要根据批次号更新采购单价子表价格
|
if (!saveSupplyRequestSuccess) {
|
||||||
|
return R.fail();
|
||||||
|
}
|
||||||
|
// 生成收费项目charge_item
|
||||||
|
ChargeItem chargeItem = new ChargeItem();
|
||||||
|
// 如果字段很少建议手动set赋值
|
||||||
|
chargeItem.setUnitPrice(supplyRequestDto.getUnitPrice());
|
||||||
|
boolean saveChargeItemSuccess = chargeItemService.saveChargeItem(chargeItem);
|
||||||
|
// 如果采购单价被修改了,需要根据批次号更新采购单价子表价格、
|
||||||
|
|
||||||
|
// if (saveChargeItemSuccess) {
|
||||||
|
// return R.ok();
|
||||||
|
// } else {
|
||||||
|
// return R.fail();
|
||||||
|
// }
|
||||||
|
return saveChargeItemSuccess ? R.ok() : R.fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright ©2023 CJB-CNIT Team. All rights reserved
|
||||||
|
*/
|
||||||
|
package com.openhis.web.InventoryManage.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ZhangYC
|
||||||
|
* @date 2025-02-20
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class SupplyRequestDto {
|
||||||
|
|
||||||
|
/** 项目 */
|
||||||
|
private String itemTable;
|
||||||
|
|
||||||
|
/** 数量 */
|
||||||
|
private Integer itemQuantity;
|
||||||
|
|
||||||
|
/** 物品编码 */
|
||||||
|
private Long code;
|
||||||
|
|
||||||
|
/** 物品计量单位 */
|
||||||
|
private String unitIdCode;
|
||||||
|
|
||||||
|
/** 物品数量 */
|
||||||
|
private Integer unitQuantity;
|
||||||
|
|
||||||
|
/** 请求细节 */
|
||||||
|
private String detailJson;
|
||||||
|
|
||||||
|
/** 期望时间 */
|
||||||
|
private Date occurrenceTime;
|
||||||
|
|
||||||
|
/** 供应人 */
|
||||||
|
private Long practitionerId;
|
||||||
|
|
||||||
|
/** 供应商 */
|
||||||
|
private Long supplierId;
|
||||||
|
|
||||||
|
/** 单位 */
|
||||||
|
private Long quantityUnit;
|
||||||
|
|
||||||
|
/** 单价 */
|
||||||
|
private BigDecimal unitPrice;
|
||||||
|
|
||||||
|
/** 总价 */
|
||||||
|
private BigDecimal totalPrice;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.openhis.administration.service;
|
package com.openhis.administration.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.core.common.core.domain.R;
|
||||||
import com.openhis.administration.domain.ChargeItem;
|
import com.openhis.administration.domain.ChargeItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,4 +12,10 @@ import com.openhis.administration.domain.ChargeItem;
|
|||||||
*/
|
*/
|
||||||
public interface IChargeItemService extends IService<ChargeItem> {
|
public interface IChargeItemService extends IService<ChargeItem> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存chargeItem相关信息
|
||||||
|
* @return 保存结果
|
||||||
|
*/
|
||||||
|
boolean saveChargeItem(ChargeItem chargeItem);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.openhis.administration.service.impl;
|
package com.openhis.administration.service.impl;
|
||||||
|
|
||||||
|
import com.core.common.utils.DateUtils;
|
||||||
|
import com.core.common.utils.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
@@ -7,6 +9,8 @@ import com.openhis.administration.domain.ChargeItem;
|
|||||||
import com.openhis.administration.mapper.ChargeItemMapper;
|
import com.openhis.administration.mapper.ChargeItemMapper;
|
||||||
import com.openhis.administration.service.IChargeItemService;
|
import com.openhis.administration.service.IChargeItemService;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 费用项管理Service业务层处理
|
* 费用项管理Service业务层处理
|
||||||
*
|
*
|
||||||
@@ -14,6 +18,22 @@ import com.openhis.administration.service.IChargeItemService;
|
|||||||
* @date 2025-02-20
|
* @date 2025-02-20
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@AllArgsConstructor
|
||||||
public class ChargeItemServiceImpl extends ServiceImpl<ChargeItemMapper, ChargeItem> implements IChargeItemService {
|
public class ChargeItemServiceImpl extends ServiceImpl<ChargeItemMapper, ChargeItem> implements IChargeItemService {
|
||||||
|
|
||||||
|
private final ChargeItemMapper chargeItemMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存chargeItem相关信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean saveChargeItem(ChargeItem chargeItem) {
|
||||||
|
// 假设此处有业务相关处理
|
||||||
|
if (chargeItem.getCode() == null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return chargeItemMapper.insert(chargeItem) > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user