Merge branch 'claude/sharp-rubin' into claude/gallant-shamir

This commit is contained in:
panchengyong
2026-03-14 14:27:21 +08:00
3 changed files with 104 additions and 0 deletions

View File

@@ -173,6 +173,11 @@ export function exportPurchaseOrder(params: PurchaseOrderQuery): Promise<Blob> {
return request.post('/erp/po/order/export', params, { responseType: 'blob' }) return request.post('/erp/po/order/export', params, { responseType: 'blob' })
} }
// 根据采购订单生成到货通知单
export function genArrivalNotice(orderId: number): Promise<number> {
return request.post(`/erp/po/order/genArrivalNotice/${orderId}`).then((res: any) => res.data)
}
// ============ 供应商 API使用 MOM md_vendor表 erp_po_supplier 在 my_mes 中未建) ============ // ============ 供应商 API使用 MOM md_vendor表 erp_po_supplier 在 my_mes 中未建) ============
export function getPoSupplierList(params?: { supplierName?: string; contact1?: string; pageNum?: number; pageSize?: number }): Promise<{ rows: PoSupplier[]; total: number }> { export function getPoSupplierList(params?: { supplierName?: string; contact1?: string; pageNum?: number; pageSize?: number }): Promise<{ rows: PoSupplier[]; total: number }> {

View File

@@ -28,6 +28,7 @@
<el-button @click="handleSwitchToEdit">编辑</el-button> <el-button @click="handleSwitchToEdit">编辑</el-button>
<el-button type="success" @click="handleApprove" :disabled="form.status !== 'PREPARE'">审核</el-button> <el-button type="success" @click="handleApprove" :disabled="form.status !== 'PREPARE'">审核</el-button>
<el-button type="warning" @click="handleUnapprove" :disabled="form.status !== 'APPROVED'">反审核</el-button> <el-button type="warning" @click="handleUnapprove" :disabled="form.status !== 'APPROVED'">反审核</el-button>
<el-button type="info" @click="handleGenArrivalNotice" :disabled="form.status !== 'APPROVED'">生成到货通知单</el-button>
<el-button @click="handlePrint">打印</el-button> <el-button @click="handlePrint">打印</el-button>
<el-button @click="toggleHeaderCollapse">{{ headerCollapsed ? '展开' : '收起' }}</el-button> <el-button @click="toggleHeaderCollapse">{{ headerCollapsed ? '展开' : '收起' }}</el-button>
</template> </template>
@@ -379,6 +380,7 @@ import {
approvePurchaseOrder, approvePurchaseOrder,
unapprovePurchaseOrder, unapprovePurchaseOrder,
genPurchaseOrderCode, genPurchaseOrderCode,
genArrivalNotice,
getPoSupplierList, getPoSupplierList,
getLeadInList, getLeadInList,
STATUS_MAP, STATUS_MAP,
@@ -817,6 +819,18 @@ async function handleUnapprove() {
} }
} }
// ============ Generate arrival notice ============
async function handleGenArrivalNotice() {
if (!form.orderId) return
try {
await ElMessageBox.confirm('确认根据当前采购订单生成到货通知单吗?', '生成到货通知单', { type: 'info' })
const noticeId = await genArrivalNotice(form.orderId)
ElMessage.success('到货通知单生成成功')
} catch (error: any) {
if (error !== 'cancel') console.error('生成到货通知单失败:', error)
}
}
// ============ View-mode actions ============ // ============ View-mode actions ============
function handleNewFromView() { router.push('/purchasing/order/new') } function handleNewFromView() { router.push('/purchasing/order/new') }
function handleSwitchToEdit() { function handleSwitchToEdit() {

View File

@@ -1,5 +1,7 @@
package com.ktg.mes.po.controller; package com.ktg.mes.po.controller;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@@ -26,6 +28,11 @@ import com.ktg.mes.po.service.IPoOrderService;
import com.ktg.mes.po.service.IPoOrderLineService; import com.ktg.mes.po.service.IPoOrderLineService;
import com.ktg.mes.mp.domain.MpPurchase; import com.ktg.mes.mp.domain.MpPurchase;
import com.ktg.mes.mp.mapper.MpPurchaseMapper; import com.ktg.mes.mp.mapper.MpPurchaseMapper;
import com.ktg.mes.wm.domain.WmArrivalNotice;
import com.ktg.mes.wm.domain.WmArrivalNoticeLine;
import com.ktg.mes.wm.service.IWmArrivalNoticeService;
import com.ktg.mes.wm.service.IWmArrivalNoticeLineService;
import com.ktg.system.strategy.AutoCodeUtil;
import com.ktg.common.utils.poi.ExcelUtil; import com.ktg.common.utils.poi.ExcelUtil;
import com.ktg.common.core.page.TableDataInfo; import com.ktg.common.core.page.TableDataInfo;
@@ -48,6 +55,15 @@ public class PoOrderController extends BaseController
@Autowired @Autowired
private MpPurchaseMapper mpPurchaseMapper; private MpPurchaseMapper mpPurchaseMapper;
@Autowired
private IWmArrivalNoticeService wmArrivalNoticeService;
@Autowired
private IWmArrivalNoticeLineService wmArrivalNoticeLineService;
@Autowired
private AutoCodeUtil autoCodeUtil;
/** /**
* 查询采购订单列表(明细视图 - 按行级别JOIN 订单表头+明细行) * 查询采购订单列表(明细视图 - 按行级别JOIN 订单表头+明细行)
*/ */
@@ -264,4 +280,73 @@ public class PoOrderController extends BaseController
} }
return AjaxResult.success("成功反审核 " + count + " 条订单"); return AjaxResult.success("成功反审核 " + count + " 条订单");
} }
/**
* 根据采购订单自动生成到货通知单
*/
@Log(title = "采购订单", businessType = BusinessType.INSERT)
@Transactional
@PostMapping("/genArrivalNotice/{orderId}")
public AjaxResult genArrivalNotice(@PathVariable Long orderId)
{
// 1. 查询采购订单及明细
PoOrder order = poOrderService.selectPoOrderByOrderId(orderId);
if (order == null) {
return AjaxResult.error("采购订单不存在!");
}
if (!UserConstants.ORDER_STATUS_APPROVED.equals(order.getStatus())) {
return AjaxResult.error("只有已审核的采购订单才能生成到货通知单!");
}
List<PoOrderLine> lines = poOrderLineService.selectPoOrderLineByOrderId(orderId);
if (CollUtil.isEmpty(lines)) {
return AjaxResult.error("采购订单没有物料明细,无法生成到货通知单!");
}
// 过滤出仍有未到货数量的明细行
List<PoOrderLine> pendingLines = new java.util.ArrayList<>();
for (PoOrderLine line : lines) {
BigDecimal qty = line.getQuantity() != null ? line.getQuantity() : BigDecimal.ZERO;
BigDecimal arrived = line.getArrivedQuantity() != null ? line.getArrivedQuantity() : BigDecimal.ZERO;
if (qty.subtract(arrived).compareTo(BigDecimal.ZERO) > 0) {
pendingLines.add(line);
}
}
if (pendingLines.isEmpty()) {
return AjaxResult.error("所有物料已全部到货,无需生成到货通知单!");
}
// 2. 创建到货通知单表头
WmArrivalNotice notice = new WmArrivalNotice();
notice.setNoticeCode(autoCodeUtil.genSerialCode(UserConstants.ARRIVAL_NOTICE_CODE, ""));
notice.setNoticeName("采购订单[" + order.getOrderCode() + "]到货通知单");
notice.setPoCode(order.getOrderCode());
notice.setVendorId(order.getSupplierId());
notice.setVendorCode(order.getSupplierCode());
notice.setVendorName(order.getSupplierName());
notice.setArrivalDate(order.getDeliveryDate() != null ? order.getDeliveryDate() : new Date());
notice.setStatus(UserConstants.ORDER_STATUS_PREPARE);
notice.setCreateBy(getUsername());
wmArrivalNoticeService.insertWmArrivalNotice(notice);
// 3. 创建到货通知单明细行
for (PoOrderLine line : pendingLines) {
WmArrivalNoticeLine noticeLine = new WmArrivalNoticeLine();
noticeLine.setNoticeId(notice.getNoticeId());
noticeLine.setItemId(line.getItemId());
noticeLine.setItemCode(line.getItemCode());
noticeLine.setItemName(line.getItemName());
noticeLine.setSpecification(line.getSpecification());
noticeLine.setUnitOfMeasure(line.getUnitName());
noticeLine.setUnitName(line.getUnitName());
BigDecimal qty = line.getQuantity() != null ? line.getQuantity() : BigDecimal.ZERO;
BigDecimal arrived = line.getArrivedQuantity() != null ? line.getArrivedQuantity() : BigDecimal.ZERO;
noticeLine.setQuantityArrival(qty.subtract(arrived));
noticeLine.setIqcCheck(UserConstants.NO);
noticeLine.setCreateBy(getUsername());
wmArrivalNoticeLineService.insertWmArrivalNoticeLine(noticeLine);
}
return AjaxResult.success("到货通知单生成成功", notice.getNoticeId());
}
} }