feat(采购订单): 添加合同条目关联及税率绑定功能
新增采购订单条目与合同条目的关联字段,实现税率和税率锁定的UI绑定 优化采购订单同步逻辑,支持从U8系统获取更多字段信息 调整界面文本显示,修复部分字段绑定问题
This commit is contained in:
@@ -151,6 +151,7 @@ public class ContractWindowController
|
||||
registerTabSkin(contractTab, t -> new ContractTabSkinSubContract(this));
|
||||
tabs.remove(bidVendorTab);
|
||||
Tab saleOrderTab = new Tab("销售订单");
|
||||
payPlanTab.setText("收款计划");
|
||||
tabs.add(saleOrderTab);
|
||||
registerTabSkin(saleOrderTab, tab -> new ContractTabSkinSaleOrders(this, tab));
|
||||
tabs.add(new Tab("票据"));
|
||||
@@ -166,6 +167,7 @@ public class ContractWindowController
|
||||
tabs.add(new Tab("发货单"));
|
||||
tabs.add(new Tab("签收单"));
|
||||
tabs.add(new Tab("付款单"));
|
||||
payPlanTab.setText("付款计划");
|
||||
}
|
||||
|
||||
registerTabSkin(itemTab, tab -> new ContractTabSkinItemsV2(this));
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.ecep.contract.ContractPayWay;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.controller.contract.AbstContractTableTabSkin;
|
||||
import com.ecep.contract.controller.contract.ContractWindowController;
|
||||
@@ -132,7 +133,11 @@ public class ContractTabSkinItemsV2
|
||||
taxPriceColumn.setCellFactory(TextFieldTableCell.forTableColumn(currencyStringConverter));
|
||||
|
||||
quantityColumn.setCellValueFactory(param -> param.getValue().getQuantity());
|
||||
quantityColumn.setCellFactory(QuantityTableCell.forTableColumn(new NumberStringConverter(getLocale())));
|
||||
if (getEntity().getPayWay() == ContractPayWay.PAY) {
|
||||
quantityColumn.setCellFactory(QuantityTableCell.forTableColumn(new NumberStringConverter(getLocale())));
|
||||
} else {
|
||||
quantityColumn.setCellFactory(TextFieldTableCell.forTableColumn(new NumberStringConverter(getLocale())));
|
||||
}
|
||||
|
||||
taxAmountColumn.setCellValueFactory(param -> param.getValue().getTaxAmount());
|
||||
taxAmountColumn.setCellFactory(TextFieldTableCell.forTableColumn(currencyStringConverter));
|
||||
|
||||
@@ -47,8 +47,12 @@ public class PurchaseOrderTabSkinBase
|
||||
initializeEmployeeField(controller.verifierField, viewModel.getVerifier());
|
||||
initializeEmployeeField(controller.closerField, viewModel.getCloser());
|
||||
|
||||
viewModel.getTaxRate();
|
||||
viewModel.getTaxRateLocked();
|
||||
// 税率和税率锁定绑定
|
||||
controller.taxRateField.textProperty().bindBidirectional(viewModel.getTaxRate(),
|
||||
new javafx.util.converter.NumberStringConverter(getLocale(), "#.##"));
|
||||
controller.taxRateLockedField.selectedProperty().bindBidirectional(viewModel.getTaxRateLocked());
|
||||
|
||||
viewModel.getVendorCode().bindBidirectional(controller.vendorCodeField.textProperty());
|
||||
|
||||
controller.makeDateField.textProperty().bind(viewModel.getMakerDate().map(MyDateTimeUtils::format));
|
||||
controller.verifierDateField.textProperty().bind(viewModel.getVerifierDate().map(MyDateTimeUtils::format));
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.ecep.contract.vm.PurchaseOrderViewModel;
|
||||
import com.ecep.contract.vo.PurchaseOrderVo;
|
||||
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TabPane;
|
||||
@@ -49,6 +50,9 @@ public class PurchaseOrderWindowController
|
||||
public TextField closerDateField;
|
||||
public TextField closerField;
|
||||
public Label versionLabel;
|
||||
public TextField taxRateField;
|
||||
public CheckBox taxRateLockedField;
|
||||
public TextField vendorCodeField;
|
||||
|
||||
@Autowired
|
||||
private PurchaseOrdersService service;
|
||||
|
||||
@@ -23,6 +23,11 @@ public class PurchaseOrderItemViewModel extends IdentityViewModel<PurchaseOrderI
|
||||
* 关联的库存, Inventory
|
||||
*/
|
||||
private SimpleObjectProperty<Integer> inventory = new SimpleObjectProperty<>();
|
||||
/**
|
||||
* 关联的采购合同条目, ContractItem
|
||||
*/
|
||||
private SimpleObjectProperty<Integer> contractItem = new SimpleObjectProperty<>();
|
||||
|
||||
private SimpleIntegerProperty refId = new SimpleIntegerProperty();
|
||||
private SimpleDoubleProperty quantity = new SimpleDoubleProperty();
|
||||
private SimpleDoubleProperty price = new SimpleDoubleProperty();
|
||||
@@ -36,6 +41,7 @@ public class PurchaseOrderItemViewModel extends IdentityViewModel<PurchaseOrderI
|
||||
super.updateFrom(v);
|
||||
getOrder().set(v.getOrder());
|
||||
getInventory().set(v.getInventoryId());
|
||||
getContractItem().set(v.getContractItemId());
|
||||
getRefId().set(v.getRefId());
|
||||
getQuantity().set(v.getQuantity());
|
||||
getPrice().set(v.getPrice());
|
||||
@@ -57,6 +63,10 @@ public class PurchaseOrderItemViewModel extends IdentityViewModel<PurchaseOrderI
|
||||
v.setInventoryId(inventory.get());
|
||||
modified = true;
|
||||
}
|
||||
if (!Objects.equals(contractItem.get(), v.getContractItemId())) {
|
||||
v.setContractItemId(contractItem.get());
|
||||
modified = true;
|
||||
}
|
||||
if (!Objects.equals(refId.get(), v.getRefId())) {
|
||||
v.setRefId(refId.get());
|
||||
modified = true;
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
<TableColumn fx:id="taxAmountColumn" style="-fx-alignment: center-right;"
|
||||
prefWidth="130.0" text="含税小计"/>
|
||||
<TableColumn fx:id="refIdColumn" editable="false" prefWidth="75.0" text="RefId"/>
|
||||
<TableColumn fx:id="codeColumn" editable="false" prefWidth="75.0" text="Code"/>
|
||||
<TableColumn fx:id="codeColumn" editable="false" prefWidth="75.0" text="条目编号"/>
|
||||
<TableColumn fx:id="startDateColumn" prefWidth="130.0" text="起始日期"/>
|
||||
<TableColumn fx:id="endDateColumn" prefWidth="130.0" text="截止日期"/>
|
||||
<TableColumn fx:id="creatorColumn" prefWidth="75.0" text="创建人"/>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.CheckBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.control.Tab?>
|
||||
@@ -19,8 +20,7 @@
|
||||
<?import javafx.scene.paint.Color?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<BorderPane prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="com.ecep.contract.controller.vendor.purchase.order.PurchaseOrderWindowController">
|
||||
<BorderPane prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.ecep.contract.controller.vendor.purchase.order.PurchaseOrderWindowController">
|
||||
<center>
|
||||
<TabPane fx:id="tabPane" tabClosingPolicy="UNAVAILABLE" tabMaxWidth="100.0" tabMinWidth="40.0">
|
||||
<tabs>
|
||||
@@ -44,22 +44,25 @@
|
||||
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER" />
|
||||
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER" />
|
||||
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER" />
|
||||
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER" />
|
||||
<RowConstraints fillHeight="false" maxHeight="1.7976931348623157E308" minHeight="30.0" prefHeight="80.0" vgrow="NEVER" />
|
||||
<RowConstraints fillHeight="false" maxHeight="1.7976931348623157E308" minHeight="30.0" prefHeight="42.0" vgrow="NEVER" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Label text="订单号#" />
|
||||
<Label text="供应商代码" GridPane.columnIndex="2" GridPane.rowIndex="0" />
|
||||
<Label text="采购订单编号" GridPane.rowIndex="1" />
|
||||
<TextField fx:id="refIdField" GridPane.columnIndex="1" />
|
||||
<TextField fx:id="vendorCodeField" GridPane.columnIndex="3" GridPane.rowIndex="0" />
|
||||
<TextField fx:id="codeField" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||
<Label layoutX="20.0" layoutY="28.0" text="备注" GridPane.rowIndex="6" />
|
||||
<TextArea fx:id="descriptionField" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="6" />
|
||||
<HBox alignment="CENTER_RIGHT" spacing="5.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="7">
|
||||
<Label layoutX="20.0" layoutY="28.0" text="备注" GridPane.rowIndex="7" />
|
||||
<TextArea fx:id="descriptionField" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="7" />
|
||||
<HBox alignment="CENTER_RIGHT" spacing="5.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="8">
|
||||
<children>
|
||||
<Button fx:id="saveBtn" disable="true" mnemonicParsing="false" text="保存" />
|
||||
</children>
|
||||
</HBox>
|
||||
<Label fx:id="versionLabel" text="\@Version" GridPane.rowIndex="7" />
|
||||
<Label fx:id="versionLabel" text="\@Version" GridPane.rowIndex="8" />
|
||||
<Label text="制单人" GridPane.rowIndex="2" />
|
||||
<Label text="制单日期" GridPane.columnIndex="2" GridPane.rowIndex="2" />
|
||||
<Label text="审核人" GridPane.rowIndex="3" />
|
||||
@@ -76,8 +79,12 @@
|
||||
<TextField fx:id="modifierDateField" GridPane.columnIndex="3" GridPane.rowIndex="4" />
|
||||
<TextField fx:id="closerField" GridPane.columnIndex="1" GridPane.rowIndex="5" />
|
||||
<TextField fx:id="closerDateField" GridPane.columnIndex="3" GridPane.rowIndex="5" />
|
||||
<Label text="业务员" GridPane.columnIndex="2" GridPane.rowIndex="1" />
|
||||
<TextField fx:id="employeeField" GridPane.columnIndex="3" GridPane.rowIndex="1" />
|
||||
<Label text="业务员" GridPane.columnIndex="2" GridPane.rowIndex="1" />
|
||||
<TextField fx:id="employeeField" GridPane.columnIndex="3" GridPane.rowIndex="1" />
|
||||
<Label text="税率" GridPane.rowIndex="6" />
|
||||
<TextField fx:id="taxRateField" GridPane.columnIndex="1" GridPane.rowIndex="6" />
|
||||
<Label text="税率锁定" GridPane.columnIndex="2" GridPane.rowIndex="6" />
|
||||
<javafx.scene.control.CheckBox fx:id="taxRateLockedField" GridPane.columnIndex="3" GridPane.rowIndex="6" />
|
||||
</children>
|
||||
<VBox.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
|
||||
@@ -13,6 +13,7 @@ public class PurchaseOrderItemVo implements IdentityEntity, java.io.Serializable
|
||||
|
||||
private Integer order;
|
||||
private Integer inventoryId;
|
||||
private Integer contractItemId;
|
||||
|
||||
private Integer refId;
|
||||
private Double quantity;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ecep.contract.cloud.u8;
|
||||
|
||||
import com.ecep.contract.ds.vendor.model.PurchaseOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
@@ -303,6 +304,16 @@ public class YongYouU8Repository {
|
||||
return getJdbcTemplate().queryForList("select * from PO_Podetails where ContractCode=?", code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据采购合同POID,查询合同项
|
||||
*
|
||||
* @param order 采购合同
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> findAllPurchaseOrderItemByOrder(PurchaseOrder order) {
|
||||
return getJdbcTemplate().queryForList("select * from PO_Podetails where POID=?", order.getRefId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询存货档案数据
|
||||
*
|
||||
@@ -374,5 +385,4 @@ public class YongYouU8Repository {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -848,17 +848,22 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
||||
holder.error("条目没有合同");
|
||||
return false;
|
||||
}
|
||||
String rowGUID = (String) map.get("RowGUID");
|
||||
|
||||
// 条目货物的code
|
||||
String code = (String) map.get("strCode");
|
||||
// 条目货物规格
|
||||
String spec = (String) map.get("cInvStd");
|
||||
// 条目货物名称
|
||||
String title = (String) map.get("strName");
|
||||
double amount = (double) map.get("dblQuantity");
|
||||
// 条目货物单位
|
||||
String unit = (String) map.get("strMeasureUnit");
|
||||
double amount = (double) map.get("dblQuantity");
|
||||
double taxRate = (double) map.get("dblTaxRatio");
|
||||
double taxPrice = (double) map.get("dblPrice");
|
||||
double exclusiveTaxPrice = (double) map.get("dblUntaxPrice");
|
||||
|
||||
String inventoryCatalogCode = (String) map.get("cInvCCode");
|
||||
String chiefCode = (String) map.get("strChief");
|
||||
String inventoryCode = (String) map.get("strInvoiceID");
|
||||
|
||||
String startDate = (String) map.get("dtStartDate");
|
||||
@@ -873,6 +878,11 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
||||
boolean modified = false;
|
||||
|
||||
holder.debug("条目:" + title + " x " + amount);
|
||||
|
||||
if (updateText(item::getRowId, item::setRowId, rowGUID, holder, "行号")) {
|
||||
modified = true;
|
||||
}
|
||||
|
||||
if (taxRate >= TaxRateUtils.TAX_RATE_GENERAL_OLDEST
|
||||
&& TaxRateUtils.isAfterTaxRateChangeTo13(contract.getSetupDate())) {
|
||||
holder.debug("税率 " + taxRate + "% 调整为 13%");
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.ecep.contract.ds.contract.service.ContractItemService;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.springframework.data.domain.Sort;
|
||||
@@ -30,6 +31,7 @@ import com.ecep.contract.ds.vendor.model.PurchaseOrderItem;
|
||||
import com.ecep.contract.util.NumberUtils;
|
||||
|
||||
import lombok.Setter;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
public class PurchaseOrderCtx extends AbstractYongYouU8Ctx {
|
||||
@Setter
|
||||
@@ -96,10 +98,12 @@ public class PurchaseOrderCtx extends AbstractYongYouU8Ctx {
|
||||
);
|
||||
|
||||
// 查询 U8 数据库
|
||||
List<Map<String, Object>> ds = repository.findAllPurchaseOrderItemByContractCode(contract.getCode());
|
||||
holder.debug("查找到 " + ds.size() + " 条采购订单条目记录在 " + CloudServiceConstant.U8_NAME);
|
||||
|
||||
// U8 中 PO_Podetails 表中有与合同相关的字段,而PO_Pomain表中没有, 所以需要先查询 PO_Podetails, 再根据 POID 查询 PO_Pomain,补全采购订单
|
||||
holder.debug("在 " + CloudServiceConstant.U8_NAME + " 中检索采购订单条目记录...");
|
||||
Map<PurchaseOrder, List<PurchaseOrderItem>> updateMap = new HashMap<>();
|
||||
List<Map<String, Object>> ds = repository.findAllPurchaseOrderItemByContractCode(contract.getCode());
|
||||
holder.info("根据合同号#" + contract.getCode() + ", 查找到 " + ds.size() + " 条采购订单条目");
|
||||
|
||||
for (Map<String, Object> map : ds) {
|
||||
Integer poId = (Integer) map.get("POID");
|
||||
if (poId == 0) {
|
||||
@@ -109,8 +113,9 @@ public class PurchaseOrderCtx extends AbstractYongYouU8Ctx {
|
||||
PurchaseOrder order = ordersMap.get(poId);
|
||||
if (order == null) {
|
||||
order = new PurchaseOrder();
|
||||
order.setContract(getCachedBean(ContractService.class).getById(contract.getId()));
|
||||
order.setRefId(poId);
|
||||
Contract v0 = getCachedBean(ContractService.class).getById(contract.getId());
|
||||
order.setContract(v0);
|
||||
order.setRefId((Integer) map.get("ID"));
|
||||
|
||||
order = ordersService.save(order);
|
||||
ordersMap.put(poId, order);
|
||||
@@ -200,6 +205,8 @@ public class PurchaseOrderCtx extends AbstractYongYouU8Ctx {
|
||||
String venBank = (String) map.get("cVenBank");
|
||||
String venBankAccount = (String) map.get("cVenAccount");
|
||||
|
||||
Double taxRate = (Double) map.get("iTaxRate");
|
||||
|
||||
String venCode = (String) map.get("cVenCode");
|
||||
String memo = (String) map.get("cMemo");
|
||||
|
||||
@@ -211,7 +218,7 @@ public class PurchaseOrderCtx extends AbstractYongYouU8Ctx {
|
||||
modified = true;
|
||||
}
|
||||
|
||||
if (updateNumber(order::getTaxRate, order::setTaxRate, (float) map.get("iTaxRate"), holder, "税率")) {
|
||||
if (updateNumber(order::getTaxRate, order::setTaxRate, taxRate.floatValue(), holder, "税率")) {
|
||||
modified = true;
|
||||
}
|
||||
|
||||
@@ -251,12 +258,13 @@ public class PurchaseOrderCtx extends AbstractYongYouU8Ctx {
|
||||
modified = true;
|
||||
}
|
||||
|
||||
if (!Objects.equals(order.getDescription(), memo)) {
|
||||
order.setDescription(memo);
|
||||
holder.info("描述修改为: " + memo);
|
||||
modified = true;
|
||||
if (StringUtils.hasText(memo)) {
|
||||
if (!Objects.equals(order.getDescription(), memo)) {
|
||||
order.setDescription(memo);
|
||||
holder.info("描述修改为: " + memo);
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
|
||||
updateCompanyBankAccount(order.getContract(), venBank, venBankAccount, holder);
|
||||
|
||||
return modified;
|
||||
@@ -277,6 +285,8 @@ public class PurchaseOrderCtx extends AbstractYongYouU8Ctx {
|
||||
Integer refId = (Integer) map.get("ID");
|
||||
String inventoryCode = (String) map.get("cInvCode");
|
||||
String contractCode = (String) map.get("ContractCode");
|
||||
String contractItemRowId = (String) map.get("ContractRowGUID");
|
||||
String memo = (String) map.get("cbMemo");
|
||||
|
||||
String title = (String) map.get("cInvCode");
|
||||
double quantity = (double) map.get("iQuantity");
|
||||
@@ -326,9 +336,16 @@ public class PurchaseOrderCtx extends AbstractYongYouU8Ctx {
|
||||
modified = true;
|
||||
}
|
||||
|
||||
if (!Objects.equals(item.getDescription(), contractCode)) {
|
||||
item.setDescription(contractCode);
|
||||
holder.info("描述修改为: " + contractCode);
|
||||
var contractItem = getCachedBean(ContractItemService.class).findByRowId(contractItemRowId);
|
||||
if (!Objects.equals(item.getContractItem(), contractItem)) {
|
||||
item.setContractItem(contractItem);
|
||||
holder.info("合同条目修改为: #" + contractItem.getId());
|
||||
modified = true;
|
||||
}
|
||||
|
||||
if (!Objects.equals(item.getDescription(), memo)) {
|
||||
item.setDescription(memo);
|
||||
holder.info("描述修改为: " + memo);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,13 +41,19 @@ public class ContractItem
|
||||
@ToString.Exclude
|
||||
private Contract contract;
|
||||
|
||||
/**
|
||||
* RowId,GUID
|
||||
*/
|
||||
@Column(name = "ROW_ID")
|
||||
private String rowId;
|
||||
|
||||
/**
|
||||
* 相关数据Id
|
||||
*/
|
||||
@Column(name = "REF_ID")
|
||||
private Integer refId;
|
||||
/**
|
||||
* 项目编号
|
||||
* 条目编号
|
||||
*/
|
||||
@Column(name = "ITEM_CODE")
|
||||
private String itemCode;
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
package com.ecep.contract.ds.contract.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.ds.contract.model.ContractItem;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.ecep.contract.ds.contract.model.ContractItem;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface ContractItemRepository extends JpaRepository<ContractItem, Integer>, JpaSpecificationExecutor<ContractItem> {
|
||||
|
||||
Optional<ContractItem> findByRowId(String rowId);
|
||||
|
||||
List<ContractItem> findAllByItemCode(String itemCode);
|
||||
|
||||
List<ContractItem> findByContractId(int contractId);
|
||||
|
||||
List<ContractItem> findByInventoryId(int inventoryId);
|
||||
|
||||
|
||||
}
|
||||
@@ -57,6 +57,15 @@ public class ContractItemService implements IEntityService<ContractItem>, QueryS
|
||||
return itemRepository.findById(id).map(ContractItem::toVo).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
public List<ContractItem> findAllByItemCode(String itemCode) {
|
||||
return itemRepository.findAllByItemCode(itemCode);
|
||||
}
|
||||
|
||||
public ContractItem findByRowId(String rowId) {
|
||||
return itemRepository.findByRowId(rowId).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ContractItem> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
@@ -99,7 +108,7 @@ public class ContractItemService implements IEntityService<ContractItem>, QueryS
|
||||
return itemRepository.findByContractId(contract.getId());
|
||||
}
|
||||
|
||||
public List<ContractItem> findAllByContract(ContractVo contract) {
|
||||
public List<ContractItem> findAllByContract(ContractVo contract) {
|
||||
return itemRepository.findByContractId(contract.getId());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ecep.contract.ds.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.ds.vendor.model.PurchaseOrder;
|
||||
import com.ecep.contract.vo.ContractItemVo;
|
||||
@@ -90,29 +91,28 @@ public class PurchaseOrderItemService implements IEntityService<PurchaseOrderIte
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "order", "inventory");
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "order", "inventory", "contractItem");
|
||||
|
||||
if (paramsNode.has("contractItem")) {
|
||||
ContractItemService itemService = SpringApp.getBean(ContractItemService.class);
|
||||
var contractItem = itemService.findById(paramsNode.get("contractItem").asInt());
|
||||
|
||||
if (contractItem.getInventoryId() == null) {
|
||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
||||
return builder.and(
|
||||
builder.equal(root.get("order").get("contract").get("id"), contractItem.getContractId()),
|
||||
builder.equal(root.get("inventory").get("id"), null)
|
||||
);
|
||||
});
|
||||
} else {
|
||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
||||
return builder.and(
|
||||
builder.equal(root.get("order").get("contract").get("id"), contractItem.getContractId()),
|
||||
builder.equal(root.get("inventory").get("id"), contractItem.getInventoryId())
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
// if (paramsNode.has("contractItem")) {
|
||||
// ContractItemService itemService = SpringApp.getBean(ContractItemService.class);
|
||||
// var contractItem = itemService.findById(paramsNode.get("contractItem").asInt());
|
||||
//
|
||||
// if (contractItem.getInventoryId() == null) {
|
||||
// spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
||||
// return builder.and(
|
||||
// builder.equal(root.get("order").get("contract").get("id"), contractItem.getContractId()),
|
||||
// builder.equal(root.get("inventory").get("id"), null)
|
||||
// );
|
||||
// });
|
||||
// } else {
|
||||
// spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
||||
// return builder.and(
|
||||
// builder.equal(root.get("order").get("contract").get("id"), contractItem.getContractId()),
|
||||
// builder.equal(root.get("inventory").get("id"), contractItem.getInventoryId())
|
||||
// );
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
return findAll(spec, pageable).map(PurchaseOrderItem::toVo);
|
||||
}
|
||||
@@ -158,13 +158,25 @@ public class PurchaseOrderItemService implements IEntityService<PurchaseOrderIte
|
||||
if (vo.getOrder() == null) {
|
||||
model.setOrder(null);
|
||||
} else {
|
||||
model.setOrder(SpringApp.getBean(PurchaseOrdersService.class).getById(vo.getOrder()));
|
||||
if (!Objects.equals(model.getOrder().getId(), vo.getOrder())) {
|
||||
model.setOrder(SpringApp.getBean(PurchaseOrdersService.class).getById(vo.getOrder()));
|
||||
}
|
||||
}
|
||||
|
||||
if (vo.getInventoryId() == null) {
|
||||
model.setInventory(null);
|
||||
} else {
|
||||
model.setInventory(SpringApp.getBean(InventoryService.class).getById(vo.getInventoryId()));
|
||||
if (!Objects.equals(model.getInventory().getId(), vo.getInventoryId())) {
|
||||
model.setInventory(SpringApp.getBean(InventoryService.class).getById(vo.getInventoryId()));
|
||||
}
|
||||
}
|
||||
|
||||
if (vo.getContractItemId() == null) {
|
||||
model.setContractItem(null);
|
||||
} else {
|
||||
if (!Objects.equals(model.getContractItem().getId(), vo.getContractItemId())) {
|
||||
model.setContractItem(SpringApp.getBean(ContractItemService.class).getById(vo.getContractItemId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -141,6 +141,8 @@ public class PurchaseOrder
|
||||
vo.setCode(code);
|
||||
vo.setRefId(refId);
|
||||
vo.setVendorCode(vendorCode);
|
||||
vo.setTaxRate(taxRate);
|
||||
vo.setTaxRateLocked(taxRateLocked);
|
||||
|
||||
vo.setMakerDate(makerDate);
|
||||
vo.setModifyDate(modifyDate);
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ecep.contract.ds.vendor.model;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.ds.contract.model.ContractItem;
|
||||
import com.ecep.contract.model.BasedEntity;
|
||||
import com.ecep.contract.model.IdentityEntity;
|
||||
import com.ecep.contract.model.Inventory;
|
||||
@@ -50,6 +51,11 @@ public class PurchaseOrderItem implements IdentityEntity, BasedEntity, Voable<Pu
|
||||
@JoinColumn(name = "INVENTORY_ID")
|
||||
@ToString.Exclude
|
||||
private Inventory inventory;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "CONTRACT_ITEM_ID")
|
||||
@ToString.Exclude
|
||||
private ContractItem contractItem;
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
@@ -110,6 +116,7 @@ public class PurchaseOrderItem implements IdentityEntity, BasedEntity, Voable<Pu
|
||||
vo.setOrder(order != null ? order.getId() : null);
|
||||
vo.setRefId(refId);
|
||||
vo.setInventoryId(inventory != null ? inventory.getId() : null);
|
||||
vo.setContractItemId(contractItem != null ? contractItem.getId() : null);
|
||||
vo.setQuantity(quantity);
|
||||
vo.setPrice(price);
|
||||
vo.setTaxRate(taxRate);
|
||||
|
||||
Reference in New Issue
Block a user