借料入库查询调整
This commit is contained in:
		
							parent
							
								
									f1349eaefc
								
							
						
					
					
						commit
						6b95f2e078
					
				|  | @ -51,6 +51,7 @@ import java.util.Map; | |||
| public class PickmToGeneralInAction implements ICommonAction { | ||||
| 
 | ||||
|     public BaseDAO dao; | ||||
|     private List<Map<String, String>> rows; | ||||
| 
 | ||||
|     public BaseDAO getDao() { | ||||
|         if (dao == null) { | ||||
|  | @ -69,7 +70,7 @@ public class PickmToGeneralInAction implements ICommonAction { | |||
|             // »ñÈ¡Ö÷¼ü | ||||
|             String[] cpickmids = paramDTO.getCpickmids(); | ||||
|             String[] cpickmbids = paramDTO.getCpickmbids(); | ||||
|             List<Map<String, String>> rows = paramDTO.getRows(); | ||||
|             rows = paramDTO.getRows(); | ||||
|             if (MMValueCheck.isEmpty(cpickmids) && (null == cpickmbids || cpickmbids.length == 0)) { | ||||
|                 return null; | ||||
|             } | ||||
|  | @ -161,6 +162,7 @@ public class PickmToGeneralInAction implements ICommonAction { | |||
|             if (bodys != null) { | ||||
|                 for (GeneralInBodyVO body : bodys) { | ||||
|                     String csourcebillhid = body.getCsourcebillhid(); | ||||
|                     String csourcebillbid = body.getCsourcebillbid(); | ||||
|                     IPickmQueryService service = ServiceLocator.find(IPickmQueryService.class); | ||||
|                     AggPickmVO[] vos = service.queryBillsByPks(new String[]{csourcebillhid}); | ||||
|                     if (vos != null && vos.length > 0) { | ||||
|  | @ -169,6 +171,25 @@ public class PickmToGeneralInAction implements ICommonAction { | |||
|                         String projectName = (String) hybo.findColValue(ProjectHeadVO.getDefaultTableName(), ProjectHeadVO.PROJECT_NAME, "pk_project = '" + cprojectid + "' "); | ||||
|                         body.setVnotebody(projectName); | ||||
|                     } | ||||
|                     if (rows != null && !rows.isEmpty()) { | ||||
|                         if (csourcebillbid == null && csourcebillbid.isEmpty()) { | ||||
|                             continue; | ||||
|                         } | ||||
|                         Map<String, String> map = rows.stream() | ||||
|                                 .filter(obj -> csourcebillbid.equals(obj.get("cpickm_bid"))) | ||||
|                                 .findFirst() | ||||
|                                 .orElse(null); | ||||
|                         if (map != null && !map.isEmpty()) { | ||||
|                             String pk_batchcode = map.get("pk_batchcode"); | ||||
|                             String vbatchcode = map.get("vbatchcode"); | ||||
|                             String cprojectid = map.get("cprojectid"); | ||||
|                             String cproductorid = map.get("cproductorid"); | ||||
|                             body.setPk_batchcode(pk_batchcode);// 批次主键 | ||||
|                             body.setVbatchcode(vbatchcode);// 批次号 | ||||
|                             body.setCprojectid(cprojectid);// 项目 | ||||
|                             body.setCproductorid(cproductorid);// 生产厂商 | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  |  | |||
|  | @ -1,11 +1,19 @@ | |||
| package nccloud.web.mmpac.pickm.query; | ||||
| 
 | ||||
| import nc.bs.trade.business.HYPubBO; | ||||
| 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.ml.NCLangRes4VoTransl; | ||||
| import nc.vo.mmpac.pickm.entity.AggPickmVO; | ||||
| import nc.vo.pub.lang.UFBoolean; | ||||
| 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; | ||||
|  | @ -13,17 +21,13 @@ 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.ArrayList; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.*; | ||||
| 
 | ||||
| /** | ||||
|  * 备料计划列表-借料入库弹窗-查询 | ||||
|  | @ -37,77 +41,124 @@ public class PickmByIdsQueryAction implements ICommonAction { | |||
|         IJson json = JsonFactory.create(); | ||||
|         PickmQueryInfoDTO query = json.fromJson(read, PickmQueryInfoDTO.class); | ||||
|         try { | ||||
|             String pageid ="50080102_card"; | ||||
|             String pageid = query.getPageid(); | ||||
|             String appcode = query.getAppcode(); | ||||
|             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<Row> list=new ArrayList<>(); | ||||
|             List<Grid> bodyList = new ArrayList<>(); | ||||
|             List<PickmItemVO> bids = new ArrayList<>(); | ||||
|             Map<String, PickmHeadVO> pickmHeadMap = new HashMap<>(); | ||||
|             for (AggPickmVO vo : vos) { | ||||
|                 if(vo.getParentVO().getFbillstatus()!=-1){ | ||||
|                     BillCardOperator operator = new BillCardOperator(pageid); | ||||
|                     BillCard billCard = operator.toCard(vo); | ||||
|                     if(billCard.getBody()==null){ | ||||
|                 PickmHeadVO headVO = vo.getParentVO(); | ||||
|                 if (FbillstatusEnum.AUDIT_STATE.equalsValue(headVO.getFbillstatus())) { | ||||
|                     PickmItemVO[] itemVOS = (PickmItemVO[]) vo.getChildren(PickmItemVO.class); | ||||
|                     if (itemVOS == null || itemVOS.length == 0) { | ||||
|                         continue; | ||||
|                     } | ||||
|                     List<Row> rows = List.of(billCard.getBody().getModel().getRows()); | ||||
|                     for (Row row:rows){ | ||||
|                         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; | ||||
|                     Set<String> 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); | ||||
|                         } | ||||
|                         Cell borrowedQtyCell = new Cell(); | ||||
|                         borrowedQtyCell.setValue(borrowedQty); | ||||
|                         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 | ||||
|                         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(vo.getParentVO().getVbillcode()); | ||||
|                         row.getValues().put("vbillcode", vbillcode); | ||||
|                         list.add(row); | ||||
| 
 | ||||
|                         // 来源计划单号	取备料计划表头 | ||||
|                         Cell vsourcebillcode = new Cell(); | ||||
|                         vsourcebillcode.setValue(vo.getParentVO().getVsourcebillcode()); | ||||
|                         row.getValues().put("vsourcebillcode", vsourcebillcode); | ||||
|                         list.add(row); | ||||
|                     } | ||||
| 
 | ||||
| //                    bodyList.add(billCard.getBody()); | ||||
|                     if (!MMValueCheck.isEmpty(codeSet)) { | ||||
|                         String codeStr = String.join(",", codeSet); | ||||
|                         ExceptionUtils.wrapBusinessException("存在有关联的其它入库,单号:" + codeStr); | ||||
|                     } | ||||
|                     // 备料计划主表 | ||||
|                     pickmHeadMap.put(headVO.getCpickmid(), headVO); | ||||
|                 } | ||||
|             } | ||||
|             Grid grid = new Grid(); | ||||
|             GridModel model = new GridModel(); | ||||
|             model.add(list); | ||||
|             grid.setModel(model); | ||||
|             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) { | ||||
|                 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> list1 = new HashMap<>(); | ||||
|             list1.put("rows",list); | ||||
|             returnMap.put("data", list1); | ||||
|             returnMap.put("data", grid); | ||||
|             returnMap.put("success", true); | ||||
|             return returnMap; | ||||
|         } catch (Exception ex) { | ||||
|  | @ -118,4 +169,16 @@ public class PickmByIdsQueryAction implements ICommonAction { | |||
|             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; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -68,12 +68,12 @@ | |||
|   </action> | ||||
|   <action> | ||||
|     <name>mmpac.pickm.pickmItemsQuery</name> | ||||
|     <label>备料计划-借料入库弹窗-数据校验</label> | ||||
|     <label>备料计划卡片-借料入库弹窗-查询</label> | ||||
|     <clazz>nccloud.web.mmpac.pickm.query.PickmItemsQuery</clazz> | ||||
|   </action> | ||||
|   <action> | ||||
|     <name>mmpac.pickm.pickmByIdsQuery</name> | ||||
|     <label>备料计划-借料入库弹窗-列表查询</label> | ||||
|     <label>备料计划列表-借料入库弹窗-查询</label> | ||||
|     <clazz>nccloud.web.mmpac.pickm.query.PickmByIdsQueryAction</clazz> | ||||
|   </action> | ||||
| </actions> | ||||
		Loading…
	
		Reference in New Issue