Commit 36592699 authored by 顾俭's avatar 顾俭

aship/aship#1 防伪码功能:申请防伪码接口

parent d1a7c884
......@@ -71,6 +71,7 @@ public class PoDtlFile extends IdentifiableObject {
private Long erpOrderId;
private String remark;
private String statusCode;
private BigDecimal appliedAmount;
@Transient
private BigDecimal relationAmount;
private String projectNumber;
......@@ -418,4 +419,14 @@ public class PoDtlFile extends IdentifiableObject {
public void setReturnRemark(String returnRemark) {
this.returnRemark = returnRemark;
}
@Basic
@Column(name = "APPLIED_AMOUNT", nullable = true, precision = 5)
public BigDecimal getAppliedAmount() {
return appliedAmount;
}
public void setAppliedAmount(BigDecimal appliedAmount) {
this.appliedAmount = appliedAmount;
}
}
......@@ -8,7 +8,9 @@ import com.i1.srm.am.entity.Function;
import com.i1.srm.am.entity.Resource;
import com.i1.srm.am.service.ResourcePermission;
import com.i1.srm.am.service.SecuredPage;
import com.i1.srm.purchaseOrder.dao.entity.PoDtlFile;
import com.i1.srm.purchaseOrder.dao.entity.PoMstFile;
import com.i1.srm.purchaseOrder.service.IPoDtlFileService;
import com.i1.srm.purchaseOrder.service.IPoMstFileService;
import com.i1.srm.purchaseOrder.web.dto.PoBarcodeDtlDto;
import com.i1.srm.purchaseOrder.web.dto.PoBarcodeDto;
......@@ -19,8 +21,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import static com.i1.erp.base.web.dto.SyncResponseCode.SUCCESS_CODE;
@RestController
@RequestMapping("/purchaseOrders")
......@@ -40,6 +46,9 @@ public class PoMstFileController extends AbstractController<PoMstFile, PoMstFile
@Autowired
private BarcodeGenClient barcodeGenClient;
@Autowired
private IPoDtlFileService poDtlFileService;
/**
* 申请防伪码
*
......@@ -52,13 +61,23 @@ public class PoMstFileController extends AbstractController<PoMstFile, PoMstFile
@ResponseStatus(HttpStatus.CREATED)
public SyncResponse getBarCode(@RequestBody PoBarcodeDto input) throws IOneWebRestfulException {
try {
// TODO check
String factoryUid = Objects.requireNonNull(input.getFactoryUid());
String purchaseOrderUid = Objects.requireNonNull(input.getPurchaseOrderUid());
List<PoBarcodeDtlDto> dtls = Objects.requireNonNull(input.getDtl());
return barcodeGenClient.genBarcode(input);
SyncResponse syncResponse = barcodeGenClient.genBarcode(input);
// 更新已申请数量
if (SUCCESS_CODE.equals(syncResponse.getCode())) {
for (PoBarcodeDtlDto dtl : dtls) {
Optional<PoDtlFile> opPoDtl = poDtlFileService.findByPoMstPurchaseOrderUidAndPoDtlRowAndFactoryFactoryUid(purchaseOrderUid, dtl.getPoDtlRow(), factoryUid);
if (opPoDtl.isPresent()) {
PoDtlFile poDtlFile = opPoDtl.get();
poDtlFile.setAppliedAmount(dtl.getBarcodeAmount().add(poDtlFile.getAppliedAmount() == null ? BigDecimal.ZERO : poDtlFile.getAppliedAmount()));
poDtlFileService.update(poDtlFile);
}
}
}
return syncResponse;
} catch (Exception e) {
throw new IOneWebRestfulException(e);
}
......
......@@ -47,6 +47,7 @@ public class PoDtlFileDto extends Dto<PoDtlFile> {
private String statusCode;
private String projectNumber;
private String returnRemark;
private BigDecimal appliedAmount;
//ext
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Shanghai")
......@@ -398,4 +399,12 @@ public class PoDtlFileDto extends Dto<PoDtlFile> {
public void setReturnRemark(String returnRemark) {
this.returnRemark = returnRemark;
}
public BigDecimal getAppliedAmount() {
return appliedAmount;
}
public void setAppliedAmount(BigDecimal appliedAmount) {
this.appliedAmount = appliedAmount;
}
}
......@@ -812,7 +812,7 @@ angular.module('IOne').controller('SteelCoilDlgCtrl', function ($scope, $uibModa
selectionRowHeaderWidth: 35,
enableSorting: true,
enableColumnResizing: true,
rowEditWaitInterval: -1,
rowEditWaitInterval: -1, // 不加会发生saveRow错误 造成不能再次修改
enableCellEditOnFocus: true,
columnDefs: [
{name: '物料编码', field: 'doDtlProduct.product.productUid', enableCellEdit: false, width: 110},
......
......@@ -149,9 +149,7 @@
</div>
<div class="modal-body">
<h5><strong>采购单{{selectedPurchaseOrder.poMst.purchaseOrderUid}},请填写需要申请项次的申请数量:</strong></h5>
<!--ui-grid-selection-->
<div ui-grid="barcodeGridOptions" ui-grid-resize-columns
ui-grid-edit ui-grid-row-edit ui-grid-cellNav class="grid" style="height: 300px">
<div ui-grid="barcodeGridOptions" ui-grid-edit ui-grid-row-edit ui-grid-cellNav ui-grid-resize-columns class="grid" style="height: 300px">
</div>
</div>
<div class="modal-footer">
......
......@@ -282,22 +282,23 @@ angular.module('IOne').controller('PurchaseOrderQueryController', function ($sco
// 申请防伪码
$scope.barcodeGridOptions = {
enableRowSelection: false,
enableSelectAll: true,
multiSelect: false,
selectionRowHeaderWidth: 35,
enableSorting: true,
enableColumnResizing: true,
rowEditWaitInterval: -1,
enableCellEditOnFocus: true,
columnDefs: [
{name: '项次', field: 'poDtlRow', width: 50},
{name: '物料编号', field: 'product.productUid', width: 100},
{name: '物料名称', field: 'product.name', width: 130},
{name: '物料规格', field: 'product.standard', width: 180},
{name: '申请数量', field: 'barcodeAmount', width: 80, enableCellEdit: true, type: 'number', cellClass: 'editable-field'},
{name: '订单数量', field: 'orderAmount', width: 80},
{name: '回执数量', field: 'supplierReturnedAmount', width: 80},
{name: '已交数量', field: 'deliveredAmount', width: 80},
{name: '已关联数量', field: 'relationAmount', width: 80}
{name: '项次', field: 'poDtlRow', width: 50, enableCellEdit: false},
{name: '物料编号', field: 'product.productUid', width: 110, enableCellEdit: false},
{name: '物料名称', field: 'product.name', width: 140, enableCellEdit: false},
{name: '物料规格', field: 'product.standard', width: 190, enableCellEdit: false},
{name: '申请数量', field: 'barcodeAmount', width: 90, enableCellEdit: true, type: 'number', cellClass: 'editable-field'},
{name: '可申请数量', field: 'canApplyAmount', width: 90, enableCellEdit: false},
{name: '已申请数量', field: 'appliedAmount', width: 90, enableCellEdit: false},
{name: '订单数量', field: 'orderAmount', width: 90, enableCellEdit: false},
// {name: '回执数量', field: 'supplierReturnedAmount', width: 80, enableCellEdit: false},
// {name: '已交数量', field: 'deliveredAmount', width: 80, enableCellEdit: false},
// {name: '已关联数量', field: 'relationAmount', width: 80, enableCellEdit: false}
],
data: []
};
......@@ -310,6 +311,19 @@ angular.module('IOne').controller('PurchaseOrderQueryController', function ($sco
};
$scope.genBarcodeClick = function () {
// check
var canApplyFlag = true;
angular.forEach($scope.barcodeGridOptions.data, function (item) {
if (item.barcodeAmount > item.canApplyAmount) {
UtilService.showWarn("项次" + item.poDtlRow + "申请数量:" + item.barcodeAmount + "<br>" + "不能超过可申请数量");
canApplyFlag = false;
}
});
if (!canApplyFlag) {
return;
}
// prepare input
var barcodeInput = {};
var barcodeDtlInput = [];
barcodeInput.factoryUid = $scope.selectedPurchaseOrder.factory.factoryUid;
......@@ -325,6 +339,7 @@ angular.module('IOne').controller('PurchaseOrderQueryController', function ($sco
});
barcodeInput.dtl = barcodeDtlInput;
// call api & handle response
PoMstFileService.genBarcode(barcodeInput).then(
function (response) {
if (response.data) {
......@@ -353,6 +368,7 @@ angular.module('IOne').controller('PurchaseOrderQueryController', function ($sco
$scope.barcodeGridOptions.data = response.data;
angular.forEach($scope.barcodeGridOptions.data, function (item) {
item.barcodeAmount = 0;
item.canApplyAmount = item.orderAmount - item.appliedAmount;
});
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment