diff --git a/WcfService1/BLL/lWmsPlate.cs b/WcfService1/BLL/lWmsPlate.cs index 8c4cf47..9c85e23 100644 --- a/WcfService1/BLL/lWmsPlate.cs +++ b/WcfService1/BLL/lWmsPlate.cs @@ -18,23 +18,23 @@ using System.Threading; namespace DeiNiu.wms.Logical { [Serializable] - public class lWmsPlate :lbase + public class lWmsPlate : lbase { WmsPlate _obj; public lWmsPlate() { - initialize(); + initialize(); } - - public WmsPlate getWmsPlate + + public WmsPlate getWmsPlate { get { - if (_obj == null) + if (_obj == null) { _obj = new WmsPlate(); - - } + + } _obj.operater = operId; return _obj; } @@ -61,13 +61,13 @@ namespace DeiNiu.wms.Logical { get { - if (_lop == null || _lop.operId!=operId) + if (_lop == null || _lop.operId != operId) { - // log.Debug(string.Format("_lop is null? {0},lop.operId {1}, operId {2}", _lop == null, lop.operId, operId)); + // log.Debug(string.Format("_lop is null? {0},lop.operId {1}, operId {2}", _lop == null, lop.operId, operId)); _lop = new lWmsOutPickRequest(operId); } - + return _lop; } } @@ -77,14 +77,14 @@ namespace DeiNiu.wms.Logical { initialize(); } - - - /// - /// get all data - /// + + + /// + /// get all data + /// public DataSet getAllData() { - return _obj.Query(); + return _obj.Query(); } /// @@ -97,13 +97,13 @@ namespace DeiNiu.wms.Logical - /// - /// get a record by id - /// + /// + /// get a record by id + /// public void initialize(int id) - { + { _obj = id != 0 ? new WmsPlate(id) : new WmsPlate(); - } + } /// /// get a record by id 0 @@ -113,41 +113,41 @@ namespace DeiNiu.wms.Logical initialize(0); } - /// + /// /// get a record by id /// public void initialize(DataRow dr) { - _obj = new WmsPlate(dr); + _obj = new WmsPlate(dr); } - + protected override DeiNiu.Data.BaseObject.BaseModel getModel() { return _obj; } - + //begin cust db operation, query, excute sql etc. - - internal int add(WmsPlate obj,int count) + + internal int add(WmsPlate obj, int count) { for (int i = 0; i < count; i++) { obj.inPlate = ""; - + obj.Add(); - obj.plateId = Util.getBoxId((enumPlateLevel)obj.type, obj.color, plateStk.getNextSeq("seqplate" + obj.type + obj.color)); + obj.plateId = Util.getBoxId((enumPlateLevel)obj.type, obj.color, plateStk.getNextSeq("seqplate" + obj.type + obj.color)); obj.Update(); - + } return 1; } - + /// /// put goods into a plate /// - - public enumRegPlateResult inPlate(string plateId,enumPlateStatus type, string goodsId,string barcode,int skuId,decimal count,string orderNo) + + public enumRegPlateResult inPlate(string plateId, enumPlateStatus type, string goodsId, string barcode, int skuId, decimal count, string orderNo) { /*if (valid( plateId, type, goodsId, skuId) == enumRegPlateResult.成功) { @@ -206,7 +206,7 @@ namespace DeiNiu.wms.Logical return enumRegPlateResult.成功; } - + private enumRegPlateResult valid(string plateId, enumPlateStatus type, string goodsId, int skuId) { @@ -224,12 +224,12 @@ namespace DeiNiu.wms.Logical { return enumRegPlateResult.成功; } - + } WmsGoods wg = new WmsGoods(goodsId); foreach (DataRow dr in dt.Rows) { - if ( Convert.ToInt32(dr["goodsType"].ToString()) == wg.goodsType)//存在goods type + if (Convert.ToInt32(dr["goodsType"].ToString()) == wg.goodsType)//存在goods type { return enumRegPlateResult.成功; } @@ -239,10 +239,10 @@ namespace DeiNiu.wms.Logical return enumRegPlateResult.容器已被不同库区或类型物品使用; - } - + } - return enumRegPlateResult.成功; + + return enumRegPlateResult.成功; } /// @@ -275,11 +275,11 @@ namespace DeiNiu.wms.Logical { return enumRegPlateResult.容器空闲无任务; } - - WmsPlatePack wpp = new WmsPlatePack(); - // wpp.getUpPlateId(fromPlate); - + WmsPlatePack wpp = new WmsPlatePack(); + // wpp.getUpPlateId(fromPlate); + + wpp.plateId = toPlate; wpp.subPlateId = fromPlate; @@ -294,7 +294,7 @@ namespace DeiNiu.wms.Logical if (toP.type == (int)enumPlateLevel.客户集货) { WmsPlateStock_tmp ptmp = new WmsPlateStock_tmp(); - + if (new WmsPlatePack(toPlate, fromPlate).ID > 0) @@ -303,11 +303,11 @@ namespace DeiNiu.wms.Logical } custId = requests[0].customerId; - + List jflows = new List(); - foreach(WmsOutPickRequest wop in requests) + foreach (WmsOutPickRequest wop in requests) { jflows.Add(new WmsFlow(wop.pickOrderNo + fromPlate)); } @@ -338,7 +338,7 @@ namespace DeiNiu.wms.Logical toP.Update(); } - + DataTable dt1 = ptmp.getOutPort(ptmp.outPortId); foreach (DataRow dr1 in dt1.Rows) @@ -355,12 +355,12 @@ namespace DeiNiu.wms.Logical flow = new WmsFlow(ptmp.orderNo + ptmp.plateId); } */ - - foreach(WmsFlow flow in jflows) + + foreach (WmsFlow flow in jflows) { flow.finishedTasksPlus(operId, 1); } - + ptmp.inPlate = toPlate; ptmp.Update(); @@ -384,11 +384,11 @@ namespace DeiNiu.wms.Logical { ldTask = req.loadTruckJob; //每个订单一个装车任务,在开始分拣时生成 } - + break; } } - + WmsFlow wmsflow = new WmsFlow(ldTask); @@ -400,7 +400,7 @@ namespace DeiNiu.wms.Logical } - + toP.customerId = custId; @@ -420,10 +420,10 @@ namespace DeiNiu.wms.Logical { if (string.IsNullOrEmpty(req.loadTruckJob) && string.IsNullOrEmpty(toP.jobNo)) { - req.loadTruckJob = toP.jobNo; - req.Update(); + req.loadTruckJob = toP.jobNo; + req.Update(); } - + if (req.state == (int)enumOutStockRequestStatus.分拣完成) { @@ -437,15 +437,15 @@ namespace DeiNiu.wms.Logical req.Update(); } } - + } - + } } - + scope.Complete(); } @@ -535,7 +535,7 @@ namespace DeiNiu.wms.Logical toP.lineId = fromP.lineId; } - else if (WmsConstants.IS_PLATE_IN_LINE && toP.lineId != (fromP.lineId) && fromP.lineId > 0) + else if (WmsConstants.IS_PLATE_IN_LINE && toP.lineId != (fromP.lineId) && fromP.lineId > 0) { return enumRegPlateResult.集货线路不同; } @@ -686,7 +686,7 @@ namespace DeiNiu.wms.Logical // log.Debug(string.Format("to plate custid {0}, to plate lineid {1} ", toP.customerId, toP.lineId )); - + return enumRegPlateResult.成功; } @@ -706,7 +706,7 @@ namespace DeiNiu.wms.Logical return enumRegPlateResult.容器已完成合流集货; } - + /* @@ -732,7 +732,7 @@ namespace DeiNiu.wms.Logical */ - + List requests = getWmsPlate.getPlateRequests(fromPlate, true); @@ -746,17 +746,17 @@ namespace DeiNiu.wms.Logical } WmsPlateStock_tmp ptmp = new WmsPlateStock_tmp(); - WmsFlow jflow = new WmsFlow(); - // List jflows = new List(); + WmsFlow jflow = new WmsFlow(); + // List jflows = new List(); + - WmsPlate toP = new WmsPlate(toPlate); int lineId = fromP.lineId; - if (fromP.ID == 0 || fromP.volume==0 ) //临时容器 + if (fromP.ID == 0 || fromP.volume == 0) //临时容器 { - + DataTable dt2 = ptmp.getStockLst(fromPlate); @@ -767,7 +767,7 @@ namespace DeiNiu.wms.Logical { jflow = new WmsFlow(ptmp.jobNo); //? 拣货任务?? } - + DataTable dt1 = ptmp.getOutPort(ptmp.outPortId); foreach (DataRow dr1 in dt1.Rows) @@ -796,20 +796,20 @@ namespace DeiNiu.wms.Logical toP.plateId = toPlate; toP.type = (int)enumPlateLevel.临时容器; toP.plateLevel = toP.type; - toP.lineId = lineId; + toP.lineId = lineId; } - if(WmsConstants.IS_PLATE_IN_LINE && lineId>0 && lineId != toP.lineId) + if (WmsConstants.IS_PLATE_IN_LINE && lineId > 0 && lineId != toP.lineId) { return enumRegPlateResult.集货线路不同; } - - - WmsPlatePack wpp = new WmsPlatePack(); - + + + WmsPlatePack wpp = new WmsPlatePack(); + wpp.plateId = toPlate; wpp.subPlateId = fromPlate; @@ -818,7 +818,7 @@ namespace DeiNiu.wms.Logical DataView dv = dt.DefaultView; dv.RowFilter = String.Format("orderNo='{0}'", requests[0].pickOrderNo); - + using (TransactionScope scope = new TransactionScope()) { @@ -826,21 +826,21 @@ namespace DeiNiu.wms.Logical if (jflow.ID > 0) { - jflow.finishedTasksPlus(operId,1, false, true); + jflow.finishedTasksPlus(operId, 1, false, true); } - wpp.removeUp(); - - int id= wpp.Add(); + wpp.removeUp(); + + int id = wpp.Add(); log.Debug("load truck add plate pack id " + id); - + //支持跳过线路集货,直接装车 if (string.IsNullOrEmpty(toP.transNo)) { toP.transNo = Util.getOrderNo(enumCreateOrderType.transOrder, _obj.getNextSeq(enumCreateOrderType.transOrder)); - - logPlate.Debug(string.Format("2 plate {0} start new trans {1}, top.ID {2}", toPlate, toP.transNo,toP.ID)); + + logPlate.Debug(string.Format("2 plate {0} start new trans {1}, top.ID {2}", toPlate, toP.transNo, toP.ID)); new lTmsTranRequest(operId).createSimpleTran(requests, toP);// req.transNo = toP.transNo; // return enumRegPlateResult.完成装车集货后才能装车; @@ -900,7 +900,7 @@ namespace DeiNiu.wms.Logical } } - if (WmsConstants.IS_PLATE_IN_LINE && !WmsConstants.AUTO_LOAD_TRUCK ) + if (WmsConstants.IS_PLATE_IN_LINE && !WmsConstants.AUTO_LOAD_TRUCK) { if (fromP.ID > 0) { @@ -919,7 +919,9 @@ namespace DeiNiu.wms.Logical //to release plate of Line - // 线路码头容器里面的客户容器是否已经全部装车了,如果都已装车(释放),则释放线路容器 + // 线路码头容器里面的客户容器是否已经全部装车了,如果都已装车(释放),则释放线路容器 + + if (fromP.plateLevel == (int)enumPlateLevel.客户集货) { @@ -936,12 +938,12 @@ namespace DeiNiu.wms.Logical } } - - + + string ldTask = fromP.jobNo; - // if (string.IsNullOrEmpty(ldTask)) // 非固定容器、非客户集货类型的容器,容器没有装车任务信息 + // if (string.IsNullOrEmpty(ldTask)) // 非固定容器、非客户集货类型的容器,容器没有装车任务信息 { foreach (WmsOutPickRequest req in requests) //容器里可能有多个分拣单,多个装车任务 { @@ -954,7 +956,7 @@ namespace DeiNiu.wms.Logical } //客户容器的装车任务 - + scope.Complete(); @@ -965,19 +967,19 @@ namespace DeiNiu.wms.Logical internal enumRegPlateResult startTran(string plateId) { WmsPlate plate = new WmsPlate(plateId); - + if (plate.ID > 0 && plate.type != (int)enumPlateLevel.运输车) { - // return enumRegPlateResult.发车需要运输类型的容器; + // return enumRegPlateResult.发车需要运输类型的容器; } - + if (string.IsNullOrEmpty(plate.transNo)) { return enumRegPlateResult.容器空闲无任务; } - + TmsTranRequest tmsTranRequest = new TmsTranRequest(plate.transNo); if (tmsTranRequest.state == (int)enumTranStatus.配送途中) { @@ -994,7 +996,7 @@ namespace DeiNiu.wms.Logical } } - + plate.partion = 0; @@ -1002,7 +1004,7 @@ namespace DeiNiu.wms.Logical Thread threadPreProcess = new Thread(new ParameterizedThreadStart(porcessStock4TransStart)); threadPreProcess.IsBackground = true; threadPreProcess.Start(plate); - + return enumRegPlateResult.成功; } @@ -1045,23 +1047,23 @@ namespace DeiNiu.wms.Logical foreach (DataRow dr in dt2.Rows) { wop = new WmsOutPickPort(dr); - - WmsStock st = new WmsStock(wop.locationId, Convert.ToInt32(dr["skuId"].ToString()), dr["goodsId"].ToString()); - if (wop.virtialCnt > 0) //还回未出库虚拟库存 - { - st.virtialCount -= wop.virtialCnt; - st.virtialCount = st.virtialCount > 0 ? st.virtialCount : 0; + WmsStock st = new WmsStock(wop.locationId, Convert.ToInt32(dr["skuId"].ToString()), dr["goodsId"].ToString()); - WmsStock virSt = st.getVirStock(st.goodsId); - virSt.countOuting -= wop.virtialCnt; - virSt.updateCountOut(); - } + if (wop.virtialCnt > 0) //还回未出库虚拟库存 + { + st.virtialCount -= wop.virtialCnt; + st.virtialCount = st.virtialCount > 0 ? st.virtialCount : 0; - st.countOuting -= wop.count; - st.countOuting = st.countOuting > 0 ? st.countOuting : 0; ; + WmsStock virSt = st.getVirStock(st.goodsId); + virSt.countOuting -= wop.virtialCnt; + virSt.updateCountOut(); + } - st.updateCountOut(); + st.countOuting -= wop.count; + st.countOuting = st.countOuting > 0 ? st.countOuting : 0; ; + + st.updateCountOut(); } wop.closePickPorts(req.pickOrderNo); @@ -1090,7 +1092,7 @@ namespace DeiNiu.wms.Logical { tranP.Delete(); } - + scope.Complete(); } @@ -1142,29 +1144,30 @@ namespace DeiNiu.wms.Logical - + return 0; } - public void releasePlateStock(string plateId,decimal count, int inPortId =0,int outPortId =0) + public void releasePlateStock(string plateId, decimal count, int inPortId = 0, int outPortId = 0) { - logPlate.Debug(string.Format("plateId {0},count {1},inPortId {2},outPortId {3}", plateId, count, inPortId, outPortId)); + logPlate.Debug(string.Format("plateId {0},count {1},inPortId {2},outPortId {3}", plateId, count, inPortId, outPortId)); WmsPlateStock_tmp plateStock = new WmsPlateStock_tmp(); - if(count==0 && inPortId==0 && outPortId == 0) + if (count == 0 && inPortId == 0 && outPortId == 0) { - int cnt= plateStock.releasePlate(plateId); - logPlate.Debug(string.Format("release plate {0} ",plateId)); + int cnt = plateStock.releasePlate(plateId); + logPlate.Debug(string.Format("release plate {0} ", plateId)); return; } DataTable dt; - if (inPortId > 0) { - dt = plateStock.getPlateIn(plateId, inPortId); + if (inPortId > 0) + { + dt = plateStock.getPlateIn(plateId, inPortId); } - else - - dt = plateStock.getPlateOut(plateId, outPortId); + else + + dt = plateStock.getPlateOut(plateId, outPortId); logPlate.Debug(string.Format(" stk items count {0} ", dt.Rows.Count)); foreach (DataRow dr in dt.Rows) @@ -1187,27 +1190,27 @@ namespace DeiNiu.wms.Logical } - public DataTable getPateJobsDt(string plateId, bool showSub = false) + public DataTable getPateJobsDt(string plateId, bool showSub = false) { - DataTable dt = getWmsPlate.getPateJobsDt( plateId, showSub ); + DataTable dt = getWmsPlate.getPateJobsDt(plateId, showSub); logTest.Debug(string.Format("plate {0} ,showSub {1}, all contents size {2}", plateId, showSub, dt.Rows.Count)); return dt; } internal DataTable queryRegistedPlate(string flowNo) { - return getWmsPlate.queryRegistedPlate(flowNo); + return getWmsPlate.queryRegistedPlate(flowNo); } internal DataTable getFromPlate(string flowNo) { return getWmsPlate.queryFromPlate(flowNo); } - + internal enumRegPlateResult takeOutPlate(string fromPlate, string plate) { - WmsPlatePack wpp = new WmsPlatePack(fromPlate,plate); + WmsPlatePack wpp = new WmsPlatePack(fromPlate, plate); log.Debug(string.Format("fromPlate {0}, plate {1}", fromPlate, plate)); if (wpp.ID == 0) { @@ -1227,7 +1230,7 @@ namespace DeiNiu.wms.Logical scope.Complete(); } return enumRegPlateResult.成功; - + } /// @@ -1242,20 +1245,20 @@ namespace DeiNiu.wms.Logical /// /// 是否只纠正账目,品相正确只是数量差异,则按实际拿的发 /// - internal enumOutValidResult plateValidation(string plateId,int portId,int skuId,string productDate,string validDate,string batch, decimal validationCnt, string validReason,bool finialValidation=true) + internal enumOutValidResult plateValidation(string plateId, int portId, int skuId, string productDate, string validDate, string batch, decimal validationCnt, string validReason, bool finialValidation = true) { log.Debug(string.Format("容器复核。。。。 portId {0}, skuId {1}, productDate {2}, validDate {3}, batch {4}, validationCnt {5}, validReason {6}, finialValidation {7}", - portId, skuId, productDate, validDate, batch, validationCnt, validReason, finialValidation)); - WmsPlateStock_tmp wst = new WmsPlateStock_tmp().getModelByOutPort(plateId,portId); - + portId, skuId, productDate, validDate, batch, validationCnt, validReason, finialValidation)); + WmsPlateStock_tmp wst = new WmsPlateStock_tmp().getModelByOutPort(plateId, portId); + WmsOutPickPort wpp = new WmsOutPickPort(portId); WmsOutPickDetail wpd = new WmsOutPickDetail(wpp.pickDetailId); - // WmsOrderRequest wor = new WmsOrderRequest(); - - + // WmsOrderRequest wor = new WmsOrderRequest(); + + wpp.validationCnt = validationCnt; wpp.checkBy = operId; wpp.checkTime = wpp.getDateTime(); @@ -1272,18 +1275,18 @@ namespace DeiNiu.wms.Logical log.Debug(string.Format("容器复核 原数量 {0}, 差异 {1} ", wst.count, diffCnt)); - WmsStock stk = null; + WmsStock stk = null; WmsStockRecord wsr = null; if (diffCnt != 0) - { - wst.count = validationCnt; + { + wst.count = validationCnt; wsr = new WmsStockRecord(wpp.recordId); - stk = new WmsStock(wpp.locationId, skuId); - // stk.adjustingCnt += diffCnt; + stk = new WmsStock(wpp.locationId, skuId); + // stk.adjustingCnt += diffCnt; stk.count += diffCnt; - log.Debug(string.Format("容器复核 volType {0}, 差异 {1}, pickdetail id {2} ,pick bulk cnt {3}, seeded cnt {4} pick batch cnt {5} ", wst.count, diffCnt,wpd.ID, wpd.bulkPicked,wpd.seeded,wpd.batchPicked)); + log.Debug(string.Format("容器复核 volType {0}, 差异 {1}, pickdetail id {2} ,pick bulk cnt {3}, seeded cnt {4} pick batch cnt {5} ", wst.count, diffCnt, wpd.ID, wpd.bulkPicked, wpd.seeded, wpd.batchPicked)); //少拿不补 //多拿不退 @@ -1300,17 +1303,17 @@ namespace DeiNiu.wms.Logical } using (TransactionScope scope = new TransactionScope()) - { - wpp.Update(); - + { + wpp.Update(); + if (diffCnt != 0) { string description = string.Format("\n 业务类型:{0} {5},拣货任务{1},计划数量 {2}, 实际数量{3}, 备注:{4}", "容器复核", - wpp.ID,wpp.count,validationCnt, validReason, finialValidation ? " 按拣货数量发货" :" 实物多退少补,按需求发" ); + wpp.ID, wpp.count, validationCnt, validReason, finialValidation ? " 按拣货数量发货" : " 实物多退少补,按需求发"); log.Debug(description); - int i = wpd.Update(); + int i = wpd.Update(); log.Debug(" pick detail count updated rows " + i); @@ -1333,7 +1336,7 @@ namespace DeiNiu.wms.Logical wsr.locationId = stk.locationId; wsr.operater = operId; wsr.rectype = (int)enumStockRecordType.容器复核; - + wsr.Add(); //新增记录 } @@ -1351,11 +1354,11 @@ namespace DeiNiu.wms.Logical return getWmsPlate.getLatestPlate(custId, goodsId).plateId; } - public DataTable getUnLoadTruckStks(string toPlate, int cnt) + public DataTable getUnLoadTruckStks(string toPlate, int cnt) { - log.Debug(string.Format("...... to getUnLoadTruckStks plateId {0}",toPlate)); + log.Debug(string.Format("...... to getUnLoadTruckStks plateId {0}", toPlate)); WmsPlate toP = new WmsPlate(toPlate); - return plateStk.getUnLoadTruckStks(toP.transNo,cnt); + return plateStk.getUnLoadTruckStks(toP.transNo, cnt); } public DataTable getLoadContent(string toPlate) @@ -1365,12 +1368,11 @@ namespace DeiNiu.wms.Logical internal string getGoodsById(string goodsId) { - WmsGoods goods = new WmsGoods(goodsId,0,""); - return goods.stockAvCount+""; + WmsGoods goods = new WmsGoods(goodsId, 0, ""); + return goods.stockAvCount + ""; } } } - \ No newline at end of file