diff --git a/zi-wms-pda/src/main/java/com/cim/idm/controller/NoChargeStockIn.java b/zi-wms-pda/src/main/java/com/cim/idm/controller/NoChargeStockIn.java index 2d46c76..f0d53ff 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/controller/NoChargeStockIn.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/controller/NoChargeStockIn.java @@ -224,7 +224,10 @@ public class NoChargeStockIn { String IQCFLAG=(String) list.get(0).get("IQCFLAG"); //6、创建标签 try { - Packing( makeEventInfo, "SDK","", ThisAcceptNumber, "1",ThisAcceptNumber, "N",vo.getReceiveRequestName(),vo.getReceiveRequestDetailName(),MATERIALSPECNAME,receiveAct, MAKEDATE, "","", "","", ERPLOCATION, ERPFACTORY,"", "", "","","",LOCATIONNAME,"","",MATERIALUNIT,IsBatch,IQCFLAG,sdkid); + //插入过账条码 + PackingAndSub( makeEventInfo, "SDK","", ThisAcceptNumber, "1",ThisAcceptNumber, "N",vo.getReceiveRequestName(),vo.getReceiveRequestDetailName(),MATERIALSPECNAME,receiveAct, MAKEDATE, "","", "","", ERPLOCATION, ERPFACTORY,"", "", "","","",LOCATIONNAME,"","",MATERIALUNIT,IsBatch,IQCFLAG,sdkid); + + } catch (Exception e) { e.printStackTrace(); } @@ -258,7 +261,9 @@ public class NoChargeStockIn { // SDKMP.SaveUnDoInfo(receiveAct,billcode); SDKMP.SaveUnDoInfo(billcode,commitDate);//传值错误,导致凭证信息未存储,已修改。zd.2024.9.24 //10、更新库存状态 - SDKMP.updateStockState(receiveAct,makeEventInfo,billcode); + //SDKMP.updateStockState(receiveAct,makeEventInfo,billcode); + SDKMP.updateStockState(makeEventInfo, billcode,opCode); + } return AjaxResult.me().setMessage("入库成功"); } @@ -688,8 +693,8 @@ public class NoChargeStockIn { : receiveRequestName; receiveRequestDetailName = receiveRequestDetailName.equals("") ? shipRequestDetailName : receiveRequestDetailName; - bindMap.put("ReceiveTime", eventInfo.getEventTime()); - bindMap.put("ReceiveUser", eventInfo.getEventUser()); + //bindMap.put("ReceiveTime", eventInfo.getEventTime()); + //bindMap.put("ReceiveUser", eventInfo.getEventUser()); bindMap.put("receiveRequestName", receiveRequestName); bindMap.put("receiveRequestDetailName", receiveRequestDetailName); @@ -754,7 +759,7 @@ public class NoChargeStockIn { } else { bindMap.put("oqaResultState",GenericServiceProxy.getConstantMap().OQA_State_Pre); } - bindMap.put("phase", phase); + //bindMap.put("phase", phase); //bindMap.put("supplierCharge", supplierCharge); bindMap.put("supplierName", supplierName); bindMap.put("npFlag", NPFlag); @@ -815,4 +820,218 @@ public class NoChargeStockIn { } return lastEventTimeKey; } + + public static String PackingAndSub(EventInfo eventInfo, String siteName, + String areaName, String receiveQty, String boxQuantity, + String EveryBoxQuantity, String boxFlag, String receiveRequestName, + String receiveRequestDetailName, String materialSpecName, + String receiveActNo, String makeDate, String shipRequestName, + String shipRequestDetailName, String reasonCodeType, + String reasonCode, String erpLocation, String erpFactory, + String charge, String supplierName, String NPFlag,String expirationDay,String supplierCharge, + String locationName,String phase,String specName,String materialUnit, + String IS_BATCH,String IQCFLAG,String sdkid) throws Exception { + + String receiveActNo1 = receiveActNo.substring(5); + String lastEventTimeKey = ""; + List listMaterialPacking = new ArrayList(); + SimpleDateFormat sDateFormat=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + List boxId; + float EveryBoxQuantity1 = 0; + BigDecimal everyQty = new BigDecimal(receiveQty); + BigDecimal sumQty = BigDecimal.ZERO; + try { + if (boxFlag.equals("Y")) { + float tempV = Math.round((Float.valueOf(receiveQty) - (Float + .valueOf(boxQuantity) - 1) + * Float.valueOf(EveryBoxQuantity)) * 100); + // float v=(float) (tempV/100.00); + EveryBoxQuantity1 = (float) (tempV / 100.00); + // float num=(float)(Math.round(totalPrice*100)/100) + } + + boxId = MaterialPackingServiceImpl.generateBoxID("LabelId", siteName, + boxQuantity, makeDate,"WL",erpFactory); + + MaterialSpec materialSpec = new MaterialSpec(); + MaterialSpecKey materialSpecKey = new MaterialSpecKey(); + materialSpecKey.setMaterialSpecName(materialSpecName); + materialSpecKey.setSiteName(siteName); + + materialSpec = MaterialServiceProxy.getMaterialSpecService() + .selectByKey(materialSpecKey); + + // try{ + // materialSpec=MaterialSpecServiceProxy.getMaterialSpecService().selectByKey(materialSpecKey); + // } + // catch(NotFoundSignal e) + // { + // e.s + // } + Map box_quantity = new HashMap(); + int i = 0; + for (; i < boxId.size(); i++) { + CreateInfo materialPacking = new CreateInfo(); + if (i == boxId.size() - 1) { + EveryBoxQuantity = Float.valueOf(receiveQty) - Float.valueOf(EveryBoxQuantity) * (boxId.size() - 1) + ""; + } + //470110856|1|C|75mm*1000m|SHBP01JT1202305240009|20230524|11|75 + String newBoxId = materialSpecName + "|1|" + phase + "|" + specName + "|" + boxId.get(i) + "|" + + makeDate.replace("-", "").substring(0, 8) + "|" + materialUnit + "|" + EveryBoxQuantity; + materialPacking.setMaterialPackingName(newBoxId); + materialPacking.setSiteName(siteName); + materialPacking.setContentMaterialType(""); + materialPacking.setMaterialPackingType("Box"); + + Map bindMap = new HashMap(); + bindMap.put("materialQuantity", EveryBoxQuantity); + bindMap.put("materialCreateQuantity", EveryBoxQuantity); + bindMap.put("packingState", "Created");// 标记Box是刚创建的 + bindMap.put("materialType", materialSpec.getMaterialType()); + bindMap.put("materialSpecName", materialSpecName); + bindMap.put("stockState", "Created"); + bindMap.put("holdState", "N"); + bindMap.put("areaName", areaName); + bindMap.put("createUser", eventInfo.getEventUser()); + bindMap.put("createTime", eventInfo.getEventTime()); + receiveRequestName = receiveRequestName.equals("") ? shipRequestName + : receiveRequestName; + receiveRequestDetailName = receiveRequestDetailName.equals("") ? shipRequestDetailName + : receiveRequestDetailName; + bindMap.put("ReceiveTime", eventInfo.getEventTime()); + bindMap.put("ReceiveUser", eventInfo.getEventUser()); + bindMap.put("receiveRequestName", receiveRequestName); + bindMap.put("receiveRequestDetailName", + receiveRequestDetailName); + bindMap.put("receiveRequestDetailName", + receiveRequestDetailName); + bindMap.put("SDK_ID", sdkid); + // bindMap.put("receiveRequestName", shipRequestName); + // bindMap.put("receiveRequestDetailName", + // shipRequestDetailName); + if(expirationDay==null||expirationDay.equals("")) + { + if(materialSpec.getExpirationDay()>0) + { + Date endTime=sDateFormat.parse(makeDate); + Calendar rightNow = Calendar.getInstance(); + rightNow.setTime(endTime); + if(siteName.equals("TM1")) + { + rightNow.add(Calendar.MONTH, materialSpec.getExpirationDay()); + rightNow.set(Calendar.DAY_OF_MONTH,rightNow.get(Calendar.DAY_OF_MONTH)-1); + } + else{ + rightNow.add(Calendar.MONTH, materialSpec.getExpirationDay()); + } + Date dt1 = rightNow.getTime(); + expirationDay = sDateFormat.format(dt1); + } + else + { + Date endTime=sDateFormat.parse(makeDate); + Calendar rightNow = Calendar.getInstance(); + rightNow.setTime(endTime); + rightNow.add(Calendar.MONTH, 48); + Date dt1 = rightNow.getTime(); + expirationDay = "2099-12-31 00:00:00"; + + //endTime.add(Calendar.MONTH, materialSpec.getExpirationDay()); + //endTime = (endTime).(materialSpec.getExpirationDay()); + } + //endTime.add(Calendar.MONTH, materialSpec.getExpirationDay()); + //endTime = (endTime).(materialSpec.getExpirationDay()); + } + + + //this.txtEndTime.Text = dt.ToString("yyyy年MM月dd日", System.Globalization.DateTimeFormatInfo.InvariantInfo); + bindMap.put("makeDate", makeDate); + bindMap.put("expiringDate", expirationDay.substring(0,expirationDay.indexOf(" "))+" 00:00:00"); + bindMap.put("receiveActNo", receiveActNo); + bindMap.put("reasonCodeType", reasonCodeType); + bindMap.put("reasonCode", reasonCode); + bindMap.put("erpLocation", erpLocation); + bindMap.put("erpFactory", erpFactory); + bindMap.put("stockInType", ""); + bindMap.put("unit", materialUnit); + if ("是".equals(IS_BATCH)) { + bindMap.put("charge", boxId.get(i)); + } + if ("否".equals(IQCFLAG)) { + bindMap.put("oqaResultState", GenericServiceProxy.getConstantMap().OQA_State_End); + bindMap.put("oqaResult","OK"); + bindMap.put("packingGrade", "OK"); + } else { + bindMap.put("oqaResultState",GenericServiceProxy.getConstantMap().OQA_State_Pre); + } + bindMap.put("phase", phase); + //bindMap.put("supplierCharge", supplierCharge); + bindMap.put("supplierName", supplierName); + bindMap.put("npFlag", NPFlag); + bindMap.put("locationName", locationName); + materialPacking.setUserColumns(bindMap); + + listMaterialPacking.add(materialPacking); + + String insertSql = "INSERT INTO MATERIALPACKINGSUB T (T.MATERIALPACKINGNAME,T.RECEIVEREQUESTNAME,T.RECEIVEREQUESTDETAILNAME,T.QTY) " + + "VALUES (:MATERIALPACKINGNAME, :RECEIVEREQUESTNAME,:RECEIVEREQUESTDETAILNAME,:QTY)"; + Map hashMap2 = new HashMap (); + hashMap2.put("MATERIALPACKINGNAME", newBoxId); + hashMap2.put("RECEIVEREQUESTNAME", receiveRequestName); + hashMap2.put("RECEIVEREQUESTDETAILNAME", receiveRequestDetailName); + hashMap2.put("QTY", EveryBoxQuantity); + IDMFrameServiceProxy.getSqlTemplate().update(insertSql, hashMap2); + + box_quantity.put(boxId.get(i), EveryBoxQuantity); // 防大数据float精度丢失 + + /** 计算最后一箱的数量 */ + // BigDecimal nextQty = new BigDecimal(EveryBoxQuantity); + // sumQty = sumQty.add(nextQty); + // if(nextQty.compareTo(everyQty.subtract(sumQty)) > 0) { + // EveryBoxQuantity = everyQty.subtract(sumQty).toString(); + // } + + } + + if (EveryBoxQuantity1 > 0) { + CreateInfo materialPacking = new CreateInfo(); + Map bindMap = new HashMap(); + bindMap.put("materialQuantity", EveryBoxQuantity1); + bindMap.put("materialCreateQuantity", EveryBoxQuantity1); + bindMap.put("packingState", "Created");// 标记Box是刚创建的 + + materialPacking = listMaterialPacking.get(boxId.size() - 1); + materialPacking.setUserColumns(bindMap); + + listMaterialPacking.remove(boxId.size() - 1); + listMaterialPacking.add(materialPacking); + } + + MaterialPackingServiceProxy.getMaterialPackingService().create( + eventInfo, listMaterialPacking); + + // 因为float精度问题,再更新一次 + try { + // for(CreateInfo creatInfo : listMaterialPacking) { + // String updateSql= " UPDATE MATERIALPACKING SET MATERIALCREATEQUANTITY = :QTY,MATERIALQUANTITY = :QTY" + // + " WHERE MATERIALPACKINGNAME = :MATERIALPACKINGNAME AND SITENAME = :SITENAME"; + // Map updateMap = new HashMap(); + // updateMap.put("QTY", box_quantity.get(creatInfo.getMaterialPackingName())); + // updateMap.put("MATERIALPACKINGNAME", creatInfo.getMaterialPackingName()); + // updateMap.put("SITENAME", siteName); + // IDMFrameServiceProxy.getSqlTemplate().update(updateSql, updateMap); + // } + } catch (IDMFrameDBErrorSignal e) { + // e.printStackTrace(); + log.info("创建BOX,更新大数据时失败 ==========> "); + } + + lastEventTimeKey = eventInfo.getEventTimeKey(); + + } catch (CustomException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return lastEventTimeKey; + } }