From 7b550e51cc66b0aade44431a5d6f11f7cba0ad50 Mon Sep 17 00:00:00 2001 From: mzr Date: Sun, 26 Oct 2025 10:00:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=80=9F=E6=96=99=E5=85=A5=E5=BA=93=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E4=BB=A3=E7=A0=81=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pickm/query/PickmByIdsQueryAction.java | 172 ++++++------------ .../mmpac/pickm/query/PickmItemsQuery.java | 124 +------------ 2 files changed, 55 insertions(+), 241 deletions(-) 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 387b3911..b40d5e74 100644 --- a/mmpac/src/client/nccloud/web/mmpac/pickm/query/PickmByIdsQueryAction.java +++ b/mmpac/src/client/nccloud/web/mmpac/pickm/query/PickmByIdsQueryAction.java @@ -1,19 +1,10 @@ package nccloud.web.mmpac.pickm.query; -import nc.bs.dao.BaseDAO; +import nc.bs.trade.business.HYPubBO; 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.ml.NCLangRes4VoTransl; import nc.vo.mmpac.pickm.entity.AggPickmVO; -import nc.vo.mmpac.pickm.entity.PickmHeadVO; -import nc.vo.mmpac.pickm.entity.PickmItemVO; -import nc.vo.mmpac.pickm.enumeration.FbillstatusEnum; -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; @@ -21,13 +12,17 @@ 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.GridModel; import nccloud.framework.web.ui.model.row.Cell; import nccloud.framework.web.ui.model.row.Row; +import nccloud.framework.web.ui.pattern.billcard.BillCard; +import nccloud.framework.web.ui.pattern.billcard.BillCardOperator; 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.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * 备料计划列表-借料入库弹窗-查询 @@ -41,124 +36,77 @@ public class PickmByIdsQueryAction implements ICommonAction { IJson json = JsonFactory.create(); PickmQueryInfoDTO query = json.fromJson(read, PickmQueryInfoDTO.class); try { - String pageid = query.getPageid(); - String appcode = query.getAppcode(); + String pageid ="50080102_card"; String[] pks = query.getPks(); IPickmQueryService service = ServiceLocator.find(IPickmQueryService.class); AggPickmVO[] vos = service.queryBillsByPks(pks); if (null == vos || vos.length == 0) { ExceptionUtils.wrapBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("5008100_0", "05008100-0005")); } - List bids = new ArrayList<>(); - Map pickmHeadMap = new HashMap<>(); + List list=new ArrayList<>(); + List bodyList = new ArrayList<>(); for (AggPickmVO vo : vos) { - PickmHeadVO headVO = vo.getParentVO(); - if (FbillstatusEnum.AUDIT_STATE.equalsValue(headVO.getFbillstatus())) { - PickmItemVO[] itemVOS = (PickmItemVO[]) vo.getChildren(PickmItemVO.class); - if (itemVOS == null || itemVOS.length == 0) { + if(vo.getParentVO().getFbillstatus()!=-1){ + BillCardOperator operator = new BillCardOperator(pageid); + BillCard billCard = operator.toCard(vo); + if(billCard.getBody()==null){ continue; } - Set codeSet = new HashSet<>(); - for (PickmItemVO itemVO : itemVOS) { - String cpickmbid = itemVO.getCpickm_bid(); - String countSql = "SELECT h.vbillcode" + - " FROM ic_generalin_b b" + - " LEFT JOIN ic_generalin_h h ON b.cgeneralhid = h.cgeneralhid" + - " WHERE b.dr = 0" + - " AND b.csourcebillbid = '" + cpickmbid + "'"; - String vbillcode = (String) new BaseDAO().executeQuery(countSql, new ColumnProcessor()); - if (StringUtils.isNotEmpty(vbillcode) && - !"~".equals(vbillcode) && !"null".equals(vbillcode)) { - codeSet.add(vbillcode); - } else { - bids.add(itemVO); - } - } - if (!MMValueCheck.isEmpty(codeSet)) { - String codeStr = String.join(",", codeSet); - ExceptionUtils.wrapBusinessException("存在有关联的其它入库,单号:" + codeStr); - } - // 备料计划主表 - pickmHeadMap.put(headVO.getCpickmid(), headVO); - } - } - if (MMValueCheck.isEmpty(bids)) { - Map returnMap = new HashMap<>(); - returnMap.put("data", null); - returnMap.put("success", false); - return returnMap; - } - GridOperator operator = new GridOperator(pageid); - if (MMValueCheck.isNotEmpty(appcode)) { - String templetid = NCCTempletQueryAction.getTempletIdByAppCode(appcode, pageid); - operator = new GridOperator(templetid, pageid); - } - Grid grid = operator.toGrid(bids.toArray(new PickmItemVO[0])); - Row[] rows = grid.getModel().getRows(); - + List rows = List.of(billCard.getBody().getModel().getRows()); 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 nplanoutastnum = (UFDouble) row.getValues().get("nplanoutastnum").getValue(); + UFDouble naccoutastnum = (UFDouble) row.getValues().get("naccoutastnum").getValue()!=null? (UFDouble)row.getValues().get("naccoutastnum").getValue():UFDouble.ZERO_DBL; + UFDouble nshouldastnum = (UFDouble) row.getValues().get("nshouldastnum").getValue()!=null? (UFDouble)row.getValues().get("nshouldastnum").getValue():UFDouble.ZERO_DBL; + UFDouble npscastnum = (UFDouble) row.getValues().get("npscastnum").getValue()!=null? (UFDouble)row.getValues().get("npscastnum").getValue():UFDouble.ZERO_DBL; UFDouble borrowedQty = nplanoutastnum.sub(naccoutastnum).sub(nshouldastnum).sub(npscastnum); // 新增备料数量字段,取值为:计划出库数量-累计出库数量-累计发货数量-累计委外数量 if (borrowedQty.doubleValue() <= 0) { continue; } - - // 新增借料数量字段 - Cell borrowedQtyCell = new Cell<>(); + 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); + row.getValues().put("borrowedQty", borrowedQtyCell); + // 产品编码 取备料计划表头产品编码 + Cell cmaterialvid = new Cell(); + cmaterialvid.setValue(vo.getParentVO().getCmaterialvid()); + row.getValues().put("cmaterialvid", borrowedQtyCell); + // 产品名称 取备料计划表头产品名称 + Cell cmaterialvidName = new Cell(); + HYPubBO hybo = new HYPubBO(); + Object cmaterialvidName1 = hybo.findColValue("bd_material", "name", "pk_material = '"+vo.getParentVO().getCmaterialvid()+"' "); + cmaterialvidName.setValue(cmaterialvidName1); + row.getValues().put("cmaterialvidName", cmaterialvidName); // 生产序号 取备料计划表头物料档案对应表头自定义项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 cmaterialvidDef26 = new Cell(); + Object cmaterialvidDef261 = hybo.findColValue("bd_material", "def26", "pk_material = '"+vo.getParentVO().getCmaterialvid()+"' "); + cmaterialvidDef26.setValue(cmaterialvidDef261); + row.getValues().put("cmaterialvidDef26", cmaterialvidDef26); + list.add(row); + // 备料计划单号 取备料计划表头 Cell vbillcode = new Cell(); - vbillcode.setValue(hvo.getVbillcode()); - vbillcode.setDisplay(hvo.getVbillcode()); - rowValues.put("vbillcode", vbillcode); + vbillcode.setValue(vo.getParentVO().getVbillcode()); + row.getValues().put("vbillcode", vbillcode); + list.add(row); // 来源计划单号 取备料计划表头 Cell vsourcebillcode = new Cell(); - vsourcebillcode.setValue(hvo.getVsourcebillcode()); - vsourcebillcode.setDisplay(hvo.getVsourcebillcode()); - rowValues.put("vsourcebillcode", vsourcebillcode); + vsourcebillcode.setValue(vo.getParentVO().getVsourcebillcode()); + row.getValues().put("vsourcebillcode", vsourcebillcode); + list.add(row); } - } +// bodyList.add(billCard.getBody()); + } + } + Grid grid = new Grid(); + GridModel model = new GridModel(); + model.add(list); + grid.setModel(model); Map returnMap = new HashMap<>(); - returnMap.put("data", grid); + Map list1 = new HashMap<>(); + list1.put("rows",list); + returnMap.put("data", list1); returnMap.put("success", true); return returnMap; } catch (Exception ex) { @@ -169,16 +117,4 @@ public class PickmByIdsQueryAction 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; - } - } 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 5f306c2b..0547124b 100644 --- a/mmpac/src/client/nccloud/web/mmpac/pickm/query/PickmItemsQuery.java +++ b/mmpac/src/client/nccloud/web/mmpac/pickm/query/PickmItemsQuery.java @@ -1,29 +1,15 @@ 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.*; @@ -63,106 +49,9 @@ public class PickmItemsQuery implements ICommonAction { 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", grid); + returnMap.put("data", bids); returnMap.put("success", true); return returnMap; } else { @@ -179,15 +68,4 @@ 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; - } }