From f1349eaefc091a0dba4211dfc4847bc454a54dd7 Mon Sep 17 00:00:00 2001 From: mzr <1562242162@qq.com> Date: Sun, 7 Sep 2025 11:04:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(ic):=20=E5=80=9F=E6=96=99=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E6=9F=A5=E8=AF=A2=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pickm/action/PickmToGeneralInAction.java | 2 + .../pickm/query/PickmByIdsQueryAction.java | 2 +- .../mmpac/pickm/query/PickmItemsQuery.java | 127 +++++++++++++++++- 3 files changed, 127 insertions(+), 4 deletions(-) diff --git a/mmpac/src/client/nccloud/web/mmpac/pickm/action/PickmToGeneralInAction.java b/mmpac/src/client/nccloud/web/mmpac/pickm/action/PickmToGeneralInAction.java index 1adf1bc..7ef3928 100644 --- a/mmpac/src/client/nccloud/web/mmpac/pickm/action/PickmToGeneralInAction.java +++ b/mmpac/src/client/nccloud/web/mmpac/pickm/action/PickmToGeneralInAction.java @@ -39,6 +39,7 @@ import nccloud.framework.web.json.JsonFactory; import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -68,6 +69,7 @@ public class PickmToGeneralInAction implements ICommonAction { // 获取主键 String[] cpickmids = paramDTO.getCpickmids(); String[] cpickmbids = paramDTO.getCpickmbids(); + List> rows = paramDTO.getRows(); if (MMValueCheck.isEmpty(cpickmids) && (null == cpickmbids || cpickmbids.length == 0)) { return null; } diff --git a/mmpac/src/client/nccloud/web/mmpac/pickm/query/PickmByIdsQueryAction.java b/mmpac/src/client/nccloud/web/mmpac/pickm/query/PickmByIdsQueryAction.java index 78c5fe1..fdf80f9 100644 --- a/mmpac/src/client/nccloud/web/mmpac/pickm/query/PickmByIdsQueryAction.java +++ b/mmpac/src/client/nccloud/web/mmpac/pickm/query/PickmByIdsQueryAction.java @@ -26,7 +26,7 @@ import java.util.List; import java.util.Map; /** - * 备料计划-借料入库弹窗-列表查询 + * 备料计划列表-借料入库弹窗-查询 * * @author mzr * @date 2025/7/8 diff --git a/mmpac/src/client/nccloud/web/mmpac/pickm/query/PickmItemsQuery.java b/mmpac/src/client/nccloud/web/mmpac/pickm/query/PickmItemsQuery.java index b1ac2bf..5f306c2 100644 --- a/mmpac/src/client/nccloud/web/mmpac/pickm/query/PickmItemsQuery.java +++ b/mmpac/src/client/nccloud/web/mmpac/pickm/query/PickmItemsQuery.java @@ -1,20 +1,34 @@ package nccloud.web.mmpac.pickm.query; import nc.bs.dao.BaseDAO; +import nc.itf.mmpac.pickm.IPickmQueryService; import nc.jdbc.framework.processor.ColumnProcessor; +import nc.jdbc.framework.processor.MapProcessor; import nc.util.mmf.framework.base.MMValueCheck; +import nc.vo.bd.material.MaterialVO; +import nc.vo.mmpac.pickm.consts.PickmLangConsts; +import nc.vo.mmpac.pickm.entity.PickmHeadVO; +import nc.vo.mmpac.pickm.entity.PickmItemVO; +import nc.vo.pub.BusinessException; +import nc.vo.pub.lang.UFDouble; import nccloud.commons.lang.StringUtils; import nccloud.dto.mmpac.pickm.pub.entity.PickmQueryInfoDTO; import nccloud.framework.core.exception.ExceptionUtils; import nccloud.framework.core.json.IJson; +import nccloud.framework.service.ServiceLocator; import nccloud.framework.web.action.itf.ICommonAction; import nccloud.framework.web.container.IRequest; import nccloud.framework.web.json.JsonFactory; +import nccloud.framework.web.ui.model.row.Cell; +import nccloud.framework.web.ui.model.row.Row; +import nccloud.framework.web.ui.pattern.grid.Grid; +import nccloud.framework.web.ui.pattern.grid.GridOperator; +import nccloud.web.mmpub.pub.action.NCCTempletQueryAction; import java.util.*; /** - * 备料计划-借料入库弹窗-数据校验 + * 备料计划卡片-借料入库弹窗-查询 * * @author mzr * @date 2025/7/8 @@ -44,15 +58,111 @@ public class PickmItemsQuery implements ICommonAction { } else { bids.add(cpickmbid); } - } if (MMValueCheck.isEmpty(bids)) { String codeStr = String.join(",", codeSet); ExceptionUtils.wrapBusinessException("存在有关联的其它入库,单号:" + codeStr); } + IPickmQueryService service = ServiceLocator.find(IPickmQueryService.class); + PickmItemVO[] itemVOS = service.queryItemsByIds(bids.toArray(new String[0])); + if (MMValueCheck.isEmpty(itemVOS)) { + ExceptionUtils.wrapBusinessException(PickmLangConsts.getHIT_BODYNOTNULL()); + } + GridOperator operator = new GridOperator(queryInfo.getPageid()); + if (MMValueCheck.isNotEmpty(queryInfo.getAppcode())) { + String templetid = NCCTempletQueryAction.getTempletIdByAppCode(queryInfo.getAppcode(), queryInfo.getPageid()); + operator = new GridOperator(templetid, queryInfo.getPageid()); + } + // HYPubBO hybo = new HYPubBO(); + Grid grid = operator.toGrid(itemVOS); + Row[] rows = grid.getModel().getRows(); + // 收集所有唯一的cpickmid + Set pickmIdSet = new HashSet<>(); + for (Row row : rows) { + Map rowValues = row.getValues(); + String cpickmid = (String) rowValues.get("cpickmid").getValue(); + if (cpickmid != null && !cpickmid.isEmpty()) { + pickmIdSet.add(cpickmid); + } + } + + // 批量查询所有需要的PickmHeadVO + Map pickmHeadMap = new HashMap<>(); + if (!pickmIdSet.isEmpty()) { + String[] pickmIds = pickmIdSet.toArray(new String[0]); + PickmHeadVO[] headVOs = service.queryHeadByIds(pickmIds); + if (headVOs != null) { + for (PickmHeadVO headVO : headVOs) { + if (headVO != null && headVO.getCpickmid() != null) { + pickmHeadMap.put(headVO.getCpickmid(), headVO); + } + } + } + } + + for (Row row : rows) { + Map rowValues = row.getValues(); + String cpickmid = (String) rowValues.get("cpickmid").getValue(); + PickmHeadVO hvo = pickmHeadMap.get(cpickmid); + + UFDouble nplanoutastnum = (UFDouble) rowValues.get("nplanoutastnum").getValue(); + UFDouble naccoutastnum = rowValues.get("naccoutastnum").getValue() != null ? (UFDouble) rowValues.get("naccoutastnum").getValue() : UFDouble.ZERO_DBL; + UFDouble nshouldastnum = rowValues.get("nshouldastnum").getValue() != null ? (UFDouble) rowValues.get("nshouldastnum").getValue() : UFDouble.ZERO_DBL; + UFDouble npscastnum = rowValues.get("npscastnum").getValue() != null ? (UFDouble) rowValues.get("npscastnum").getValue() : UFDouble.ZERO_DBL; + UFDouble borrowedQty = nplanoutastnum.sub(naccoutastnum).sub(nshouldastnum).sub(npscastnum); + // 新增备料数量字段,取值为:计划出库数量-累计出库数量-累计发货数量-累计委外数量 + if (borrowedQty.doubleValue() <= 0) { + continue; + } + + // 新增借料数量字段 + Cell borrowedQtyCell = new Cell<>(); + borrowedQtyCell.setValue(borrowedQty); + rowValues.put("borrowedQty", borrowedQtyCell); + if (hvo != null) { + // 产品编码 + String cmaterialvid = hvo.getCmaterialvid(); + Cell cmaterialvidCell = new Cell<>(); + cmaterialvidCell.setValue(cmaterialvid); + if (cmaterialvid != null && !cmaterialvid.isEmpty()) { + Map materialMap = getMapValByCondition(MaterialVO.getDefaultTableName(), "code,name,def26", + MaterialVO.PK_MATERIAL + " = '" + cmaterialvid + "' "); + if (materialMap != null) { + cmaterialvidCell.setValue(cmaterialvid); + cmaterialvidCell.setDisplay((materialMap.getOrDefault(MaterialVO.CODE, "") + "")); + rowValues.put("cmaterialvid", cmaterialvidCell); + // 物料名称 + Cell materialCell = new Cell<>(); + materialCell.setDisplay(materialMap.getOrDefault(MaterialVO.NAME, "") + ""); + materialCell.setValue(materialMap.getOrDefault(MaterialVO.NAME, "")); + rowValues.put("cmaterialvid.name", materialCell); + // 生产序号 取备料计划表头物料档案对应表头自定义项26 + materialCell = new Cell<>(); + Object def26 = ""; + if (materialMap.getOrDefault(MaterialVO.DEF26, "") != null) { + def26 = materialMap.getOrDefault(MaterialVO.DEF26, ""); + } + materialCell.setDisplay(def26 + ""); + materialCell.setValue(def26); + rowValues.put("cmaterialvid.def26", materialCell); + } + } + // 备料计划单号 取备料计划表头 + Cell vbillcode = new Cell(); + vbillcode.setValue(hvo.getVbillcode()); + vbillcode.setDisplay(hvo.getVbillcode()); + rowValues.put("vbillcode", vbillcode); + + // 来源计划单号 取备料计划表头 + Cell vsourcebillcode = new Cell(); + vsourcebillcode.setValue(hvo.getVsourcebillcode()); + vsourcebillcode.setDisplay(hvo.getVsourcebillcode()); + rowValues.put("vsourcebillcode", vsourcebillcode); + } + } Map returnMap = new HashMap<>(); - returnMap.put("data", bids); + returnMap.put("data", grid); returnMap.put("success", true); return returnMap; } else { @@ -69,4 +179,15 @@ public class PickmItemsQuery implements ICommonAction { return returnMap; } } + + public Map getMapValByCondition(String tableName, String fieldName, String condition) throws BusinessException { + String sql = " SELECT " + fieldName + " FROM " + tableName + " " + + " WHERE nvl(" + tableName + " .dr,0)= 0 " + + " and " + condition + " "; + Map result = (Map) new BaseDAO().executeQuery(sql, new MapProcessor()); + if (result == null || result.isEmpty()) { + result = new HashMap<>(); + } + return result; + } }