借料入库查询代码回退

This commit is contained in:
mzr 2025-10-26 10:00:10 +08:00
parent 7c44dd64b0
commit 7b550e51cc
2 changed files with 55 additions and 241 deletions

View File

@ -1,19 +1,10 @@
package nccloud.web.mmpac.pickm.query; 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.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.ml.NCLangRes4VoTransl;
import nc.vo.mmpac.pickm.entity.AggPickmVO; 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 nc.vo.pub.lang.UFDouble;
import nccloud.commons.lang.StringUtils;
import nccloud.dto.mmpac.pickm.pub.entity.PickmQueryInfoDTO; import nccloud.dto.mmpac.pickm.pub.entity.PickmQueryInfoDTO;
import nccloud.framework.core.exception.ExceptionUtils; import nccloud.framework.core.exception.ExceptionUtils;
import nccloud.framework.core.json.IJson; 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.action.itf.ICommonAction;
import nccloud.framework.web.container.IRequest; import nccloud.framework.web.container.IRequest;
import nccloud.framework.web.json.JsonFactory; 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.Cell;
import nccloud.framework.web.ui.model.row.Row; 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.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(); IJson json = JsonFactory.create();
PickmQueryInfoDTO query = json.fromJson(read, PickmQueryInfoDTO.class); PickmQueryInfoDTO query = json.fromJson(read, PickmQueryInfoDTO.class);
try { try {
String pageid = query.getPageid(); String pageid ="50080102_card";
String appcode = query.getAppcode();
String[] pks = query.getPks(); String[] pks = query.getPks();
IPickmQueryService service = ServiceLocator.find(IPickmQueryService.class); IPickmQueryService service = ServiceLocator.find(IPickmQueryService.class);
AggPickmVO[] vos = service.queryBillsByPks(pks); AggPickmVO[] vos = service.queryBillsByPks(pks);
if (null == vos || vos.length == 0) { if (null == vos || vos.length == 0) {
ExceptionUtils.wrapBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("5008100_0", "05008100-0005")); ExceptionUtils.wrapBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("5008100_0", "05008100-0005"));
} }
List<PickmItemVO> bids = new ArrayList<>(); List<Row> list=new ArrayList<>();
Map<String, PickmHeadVO> pickmHeadMap = new HashMap<>(); List<Grid> bodyList = new ArrayList<>();
for (AggPickmVO vo : vos) { for (AggPickmVO vo : vos) {
PickmHeadVO headVO = vo.getParentVO(); if(vo.getParentVO().getFbillstatus()!=-1){
if (FbillstatusEnum.AUDIT_STATE.equalsValue(headVO.getFbillstatus())) { BillCardOperator operator = new BillCardOperator(pageid);
PickmItemVO[] itemVOS = (PickmItemVO[]) vo.getChildren(PickmItemVO.class); BillCard billCard = operator.toCard(vo);
if (itemVOS == null || itemVOS.length == 0) { if(billCard.getBody()==null){
continue; continue;
} }
Set<String> codeSet = new HashSet<>(); List<Row> rows = List.of(billCard.getBody().getModel().getRows());
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<String, Object> 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();
for (Row row : rows) { for (Row row : rows) {
Map<String, Cell> rowValues = row.getValues(); UFDouble nplanoutastnum = (UFDouble) row.getValues().get("nplanoutastnum").getValue();
String cpickmid = (String) rowValues.get("cpickmid").getValue(); UFDouble naccoutastnum = (UFDouble) row.getValues().get("naccoutastnum").getValue()!=null? (UFDouble)row.getValues().get("naccoutastnum").getValue():UFDouble.ZERO_DBL;
PickmHeadVO hvo = pickmHeadMap.get(cpickmid); 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 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); UFDouble borrowedQty = nplanoutastnum.sub(naccoutastnum).sub(nshouldastnum).sub(npscastnum);
// 新增备料数量字段取值为计划出库数量-累计出库数量-累计发货数量-累计委外数量 // 新增备料数量字段取值为计划出库数量-累计出库数量-累计发货数量-累计委外数量
if (borrowedQty.doubleValue() <= 0) { if (borrowedQty.doubleValue() <= 0) {
continue; continue;
} }
Cell borrowedQtyCell = new Cell();
// 新增借料数量字段
Cell<UFDouble> borrowedQtyCell = new Cell<>();
borrowedQtyCell.setValue(borrowedQty); borrowedQtyCell.setValue(borrowedQty);
rowValues.put("borrowedQty", borrowedQtyCell); row.getValues().put("borrowedQty", borrowedQtyCell);
if (hvo != null) { // 产品编码 取备料计划表头产品编码
// 产品编码 Cell cmaterialvid = new Cell();
String cmaterialvid = hvo.getCmaterialvid(); cmaterialvid.setValue(vo.getParentVO().getCmaterialvid());
Cell<String> cmaterialvidCell = new Cell<>(); row.getValues().put("cmaterialvid", borrowedQtyCell);
cmaterialvidCell.setValue(cmaterialvid); // 产品名称 取备料计划表头产品名称
if (cmaterialvid != null && !cmaterialvid.isEmpty()) { Cell cmaterialvidName = new Cell();
Map<String, Object> materialMap = getMapValByCondition(MaterialVO.getDefaultTableName(), "code,name,def26", HYPubBO hybo = new HYPubBO();
MaterialVO.PK_MATERIAL + " = '" + cmaterialvid + "' "); Object cmaterialvidName1 = hybo.findColValue("bd_material", "name", "pk_material = '"+vo.getParentVO().getCmaterialvid()+"' ");
if (materialMap != null) { cmaterialvidName.setValue(cmaterialvidName1);
cmaterialvidCell.setValue(cmaterialvid); row.getValues().put("cmaterialvidName", cmaterialvidName);
cmaterialvidCell.setDisplay((materialMap.getOrDefault(MaterialVO.CODE, "") + ""));
rowValues.put("cmaterialvid", cmaterialvidCell);
// 物料名称
Cell<String> materialCell = new Cell<>();
materialCell.setDisplay(materialMap.getOrDefault(MaterialVO.NAME, "") + "");
materialCell.setValue(materialMap.getOrDefault(MaterialVO.NAME, ""));
rowValues.put("cmaterialvid.name", materialCell);
// 生产序号 取备料计划表头物料档案对应表头自定义项26 // 生产序号 取备料计划表头物料档案对应表头自定义项26
materialCell = new Cell<>(); Cell cmaterialvidDef26 = new Cell();
Object def26 = ""; Object cmaterialvidDef261 = hybo.findColValue("bd_material", "def26", "pk_material = '"+vo.getParentVO().getCmaterialvid()+"' ");
if (materialMap.getOrDefault(MaterialVO.DEF26, "") != null) { cmaterialvidDef26.setValue(cmaterialvidDef261);
def26 = materialMap.getOrDefault(MaterialVO.DEF26, ""); row.getValues().put("cmaterialvidDef26", cmaterialvidDef26);
} list.add(row);
materialCell.setDisplay(def26 + "");
materialCell.setValue(def26);
rowValues.put("cmaterialvid.def26", materialCell);
}
}
// 备料计划单号 取备料计划表头 // 备料计划单号 取备料计划表头
Cell vbillcode = new Cell(); Cell vbillcode = new Cell();
vbillcode.setValue(hvo.getVbillcode()); vbillcode.setValue(vo.getParentVO().getVbillcode());
vbillcode.setDisplay(hvo.getVbillcode()); row.getValues().put("vbillcode", vbillcode);
rowValues.put("vbillcode", vbillcode); list.add(row);
// 来源计划单号 取备料计划表头 // 来源计划单号 取备料计划表头
Cell vsourcebillcode = new Cell(); Cell vsourcebillcode = new Cell();
vsourcebillcode.setValue(hvo.getVsourcebillcode()); vsourcebillcode.setValue(vo.getParentVO().getVsourcebillcode());
vsourcebillcode.setDisplay(hvo.getVsourcebillcode()); row.getValues().put("vsourcebillcode", vsourcebillcode);
rowValues.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<String, Object> returnMap = new HashMap<>(); Map<String, Object> returnMap = new HashMap<>();
returnMap.put("data", grid); Map<String, Object> list1 = new HashMap<>();
list1.put("rows",list);
returnMap.put("data", list1);
returnMap.put("success", true); returnMap.put("success", true);
return returnMap; return returnMap;
} catch (Exception ex) { } catch (Exception ex) {
@ -169,16 +117,4 @@ public class PickmByIdsQueryAction implements ICommonAction {
return returnMap; return returnMap;
} }
} }
public Map<String, Object> getMapValByCondition(String tableName, String fieldName, String condition) throws BusinessException {
String sql = " SELECT " + fieldName + " FROM " + tableName + " " +
" WHERE nvl(" + tableName + " .dr,0)= 0 " +
" and " + condition + " ";
Map<String, Object> result = (Map<String, Object>) new BaseDAO().executeQuery(sql, new MapProcessor());
if (result == null || result.isEmpty()) {
result = new HashMap<>();
}
return result;
}
} }

View File

@ -1,29 +1,15 @@
package nccloud.web.mmpac.pickm.query; package nccloud.web.mmpac.pickm.query;
import nc.bs.dao.BaseDAO; import nc.bs.dao.BaseDAO;
import nc.itf.mmpac.pickm.IPickmQueryService;
import nc.jdbc.framework.processor.ColumnProcessor; import nc.jdbc.framework.processor.ColumnProcessor;
import nc.jdbc.framework.processor.MapProcessor;
import nc.util.mmf.framework.base.MMValueCheck; 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.commons.lang.StringUtils;
import nccloud.dto.mmpac.pickm.pub.entity.PickmQueryInfoDTO; import nccloud.dto.mmpac.pickm.pub.entity.PickmQueryInfoDTO;
import nccloud.framework.core.exception.ExceptionUtils; import nccloud.framework.core.exception.ExceptionUtils;
import nccloud.framework.core.json.IJson; import nccloud.framework.core.json.IJson;
import nccloud.framework.service.ServiceLocator;
import nccloud.framework.web.action.itf.ICommonAction; import nccloud.framework.web.action.itf.ICommonAction;
import nccloud.framework.web.container.IRequest; import nccloud.framework.web.container.IRequest;
import nccloud.framework.web.json.JsonFactory; 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.*; import java.util.*;
@ -63,106 +49,9 @@ public class PickmItemsQuery implements ICommonAction {
String codeStr = String.join(",", codeSet); String codeStr = String.join(",", codeSet);
ExceptionUtils.wrapBusinessException("存在有关联的其它入库,单号:" + codeStr); 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<String> pickmIdSet = new HashSet<>();
for (Row row : rows) {
Map<String, Cell> rowValues = row.getValues();
String cpickmid = (String) rowValues.get("cpickmid").getValue();
if (cpickmid != null && !cpickmid.isEmpty()) {
pickmIdSet.add(cpickmid);
}
}
// 批量查询所有需要的PickmHeadVO
Map<String, PickmHeadVO> 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<String, Cell> 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<UFDouble> borrowedQtyCell = new Cell<>();
borrowedQtyCell.setValue(borrowedQty);
rowValues.put("borrowedQty", borrowedQtyCell);
if (hvo != null) {
// 产品编码
String cmaterialvid = hvo.getCmaterialvid();
Cell<String> cmaterialvidCell = new Cell<>();
cmaterialvidCell.setValue(cmaterialvid);
if (cmaterialvid != null && !cmaterialvid.isEmpty()) {
Map<String, Object> 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<String> 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<String, Object> returnMap = new HashMap<>(); Map<String, Object> returnMap = new HashMap<>();
returnMap.put("data", grid); returnMap.put("data", bids);
returnMap.put("success", true); returnMap.put("success", true);
return returnMap; return returnMap;
} else { } else {
@ -179,15 +68,4 @@ public class PickmItemsQuery implements ICommonAction {
return returnMap; return returnMap;
} }
} }
public Map<String, Object> getMapValByCondition(String tableName, String fieldName, String condition) throws BusinessException {
String sql = " SELECT " + fieldName + " FROM " + tableName + " " +
" WHERE nvl(" + tableName + " .dr,0)= 0 " +
" and " + condition + " ";
Map<String, Object> result = (Map<String, Object>) new BaseDAO().executeQuery(sql, new MapProcessor());
if (result == null || result.isEmpty()) {
result = new HashMap<>();
}
return result;
}
} }