Exemplo n.º 1
0
        public WarehouseInOutRecord CancelWarehouseInOutRecordWithScaleBill(WarehouseStoreInfo warehouseStoreInfo, PlanTaskBatchDetail planTaskBatchDetail)
        {
            PlanTaskBatch planTaskBatch = planTaskBatchDetail.PlanTaskBatch;

            if (planTaskBatchDetail.outwarehouse != null)
            {
                //倒仓出入库记录
                //根据出仓点找到该计划批次明细对应的出入库记录
                WarehouseInOutRecord warehouseInOutRecordOut = planTaskBatch.WarehouseInOutRecords.Where(wior => wior.warehouse_id == planTaskBatchDetail.outwarehouse).FirstOrDefault();
                if (warehouseInOutRecordOut != null && planTaskBatchDetail.weight.HasValue)
                {
                    //有对应的出入库记录,则回滚出仓点信息
                    decimal dBatchCount = planTaskBatchDetail.weight.Value;
                    //对于倒仓出库,则回滚增加被扣除数量
                    warehouseInOutRecordOut.record_count  -= dBatchCount;
                    warehouseInOutRecordOut.balance_count += dBatchCount;
                    _unitOfWork.AddAction(warehouseInOutRecordOut, DAL.Enums.DataActions.Update);
                }
            }
            //不论出入库还是倒仓,都需要更新对应plantaskbatchdetail中warehouse的出入库记录
            WarehouseInOutRecord warehouseInOutRecord = planTaskBatch.WarehouseInOutRecords.Where(wior => wior.warehouse_id == planTaskBatchDetail.warehouse_id).FirstOrDefault();

            if (warehouseInOutRecord != null && planTaskBatchDetail.weight.HasValue)
            {
                decimal dBatchCount = planTaskBatchDetail.weight.Value;
                warehouseInOutRecord.record_count -= dBatchCount;
                if (planTaskBatch.PlanTask.Enrolment != null)
                {
                    if (planTaskBatch.PlanTask.Enrolment.inout_type == (int)InOutType.入库)
                    {
                        warehouseInOutRecord.balance_count -= dBatchCount;
                    }
                    else
                    {
                        warehouseInOutRecord.balance_count += dBatchCount;
                    }
                }
                else
                {
                    if (planTaskBatch.PlanTask.PlanTaskType.warehouse_control_mode == (int)WarehouseControlMode.出入仓)
                    {
                        //倒仓情况下,对应的warehouse等于入仓点,回滚入库则扣除
                        warehouseInOutRecord.balance_count -= dBatchCount;
                    }
                }
                _unitOfWork.AddAction(warehouseInOutRecord, DAL.Enums.DataActions.Update);
            }

            CancelWarehouseInOutRecordDetailWithInOutRecordAndBatchDetail(planTaskBatchDetail);
            return(warehouseInOutRecord);
        }
Exemplo n.º 2
0
        public WarehouseInOutRecord UpdateWarehouseInOutRecordWithStoreInfoAndBatchAdjust(WarehouseStoreInfo warehouseStoreInfo, PlanTaskBatchAdjust planTaskBatchAdjust, PlanTaskBatch plantaskBatch)
        {
            WarehouseInOutRecord warehouseInOutRecord = plantaskBatch.WarehouseInOutRecords.Where(t => t.warehouse_id == warehouseStoreInfo.warehouse_id).FirstOrDefault();

            if (plantaskBatch.PlanTask.PlanTaskType.warehouse_control_mode.Value == (int)WarehouseControlMode.入仓)
            {
                if (planTaskBatchAdjust.adjust_type == (int)plantaskahjusttype.增加)
                {
                    warehouseInOutRecord.record_count  += planTaskBatchAdjust.adjust_count;
                    warehouseInOutRecord.balance_count += planTaskBatchAdjust.adjust_count;
                }
                else
                {
                    warehouseInOutRecord.record_count  -= planTaskBatchAdjust.adjust_count;
                    warehouseInOutRecord.balance_count -= planTaskBatchAdjust.adjust_count;
                }
            }
            else
            {
                if (planTaskBatchAdjust.adjust_type == (int)plantaskahjusttype.增加)
                {
                    warehouseInOutRecord.record_count  += planTaskBatchAdjust.adjust_count;
                    warehouseInOutRecord.balance_count -= planTaskBatchAdjust.adjust_count;
                }
                else
                {
                    warehouseInOutRecord.record_count  -= planTaskBatchAdjust.adjust_count;
                    warehouseInOutRecord.balance_count += planTaskBatchAdjust.adjust_count;
                }
            }
            _unitOfWork.AddAction(warehouseInOutRecord, DataActions.Update);

            AddWarehouseInOutRecordDetailWithInOutRecordAndBatchAdjust(warehouseInOutRecord, planTaskBatchAdjust);
            return(warehouseInOutRecord);
        }
Exemplo n.º 3
0
        public WarehouseInOutRecord UpdateWarehouseInOutRecordWithStoreInfoAndBatchDetail(WarehouseStoreInfo warehouseStoreInfo, WarehouseStoreInfo outWarehouseStoreInfo, PlanTaskBatchDetail planTaskBatchDetail, string orgCode)
        {
            PlanTaskBatch planTaskBatch = planTaskBatchDetail.PlanTaskBatch;

            //如果是倒仓,则有出库storeinfo判定
            if (outWarehouseStoreInfo != null)
            {
                WarehouseInOutRecord outWarehouseInOutRecord = planTaskBatch.WarehouseInOutRecords.Where(t => t.warehouse_id == outWarehouseStoreInfo.warehouse_id).FirstOrDefault();
                if (outWarehouseInOutRecord == null)
                {
                    outWarehouseInOutRecord = this.AddWarehouseInOutRecordWithStoreInfoAndBatchDetail(outWarehouseStoreInfo, planTaskBatchDetail, true, orgCode, true);
                }
                else
                {
                    outWarehouseInOutRecord.record_count  += planTaskBatchDetail.weight;
                    outWarehouseInOutRecord.balance_count -= planTaskBatchDetail.weight;
                    outWarehouseInOutRecord.inout_datetime = planTaskBatchDetail.weight_time == null ? "" : planTaskBatchDetail.weight_time.Value.ToString("yyyyMMddHHmmss");
                    _unitOfWork.AddAction(outWarehouseInOutRecord, DAL.Enums.DataActions.Update);
                    AddWarehouseInOutRecordDetailWithInOutRecordAndBatchDetail(outWarehouseInOutRecord, planTaskBatchDetail);
                }
            }
            //是否需要判断批次已经完成,需要确认一下
            WarehouseInOutRecord warehouseInOutRecord = planTaskBatch.WarehouseInOutRecords.Where(t => t.warehouse_id == warehouseStoreInfo.warehouse_id).FirstOrDefault();

            if (warehouseInOutRecord == null)
            {
                //如果当前新增的批次明细所属计划批次还没有对应的出入库记录,则新增出入库记录
                warehouseInOutRecord = this.AddWarehouseInOutRecordWithStoreInfoAndBatchDetail(warehouseStoreInfo, planTaskBatchDetail, false, orgCode, false);
            }
            else
            {
                //更新出入库记录表,以及增加出入库明细表
                warehouseInOutRecord.record_count += planTaskBatchDetail.weight;
                if (planTaskBatch.PlanTask.Enrolment == null)
                {
                    warehouseInOutRecord.balance_count += planTaskBatchDetail.weight;
                }
                else
                {
                    if (planTaskBatch.PlanTask.Enrolment.inout_type == (int)InOutType.入库)
                    {
                        warehouseInOutRecord.balance_count += planTaskBatchDetail.weight;
                    }
                    else
                    {
                        warehouseInOutRecord.balance_count -= planTaskBatchDetail.weight;
                    }
                }
                warehouseInOutRecord.inout_datetime = planTaskBatchDetail.weight_time == null ? "" : planTaskBatchDetail.weight_time.Value.ToString("yyyyMMddHHmmss");
                _unitOfWork.AddAction(warehouseInOutRecord, DAL.Enums.DataActions.Update);
            }
            AddWarehouseInOutRecordDetailWithInOutRecordAndBatchDetail(warehouseInOutRecord, planTaskBatchDetail);
            return(warehouseInOutRecord);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 新建出入库记录
        /// </summary>
        /// <param name="warehouseStoreInfo">仓储保管帐信息</param>
        /// <param name="planTaskBatchDetail">计划批次明细</param>
        /// <param name="isOutWarehouseStoreInfo">是否倒仓出库标志</param>
        /// <returns>创建完成的出入库记录</returns>
        private WarehouseInOutRecord AddWarehouseInOutRecordWithStoreInfoAndBatchDetail(WarehouseStoreInfo warehouseStoreInfo, PlanTaskBatchDetail planTaskBatchDetail, bool isOutWarehouseStoreInfo, string orgCode, bool isOutInFlag)
        {
            WarehouseInOutRecord warehouseInOutRecord = null;
            PlanTaskBatch        planTaskBatch        = planTaskBatchDetail.PlanTaskBatch;

            warehouseInOutRecord = new WarehouseInOutRecord();
            int sysBillNoID = _sysBillNoService.GetBillNoID(MESSystem.whm, BillPrefix.ioh);

            //warehouseInOutRecord.record_number = AisinoMesServiceHelper.GetOriginalDept(planTaskBatch.PlanTask.Enrolment.OrganizationEmployee1) + _sysBillNoService.GetBillNo(sysBillNoID);
            if (isOutWarehouseStoreInfo)
            {
                //如果是倒仓出入,则前缀增加O
                warehouseInOutRecord.record_number = orgCode + "O" + _sysBillNoService.GetBillNo(sysBillNoID) + planTaskBatch.generate_id;
            }
            else
            {
                warehouseInOutRecord.record_number = orgCode + _sysBillNoService.GetBillNo(sysBillNoID) + planTaskBatch.generate_id;
            }
            warehouseInOutRecord.record_status = (int)RecordStatus.效;
            warehouseInOutRecord.registe_type  = (int)WarehouseInOutRecordRegisteType.系统登记;
            if (!isOutWarehouseStoreInfo)
            {
                //不是倒仓,则不论出入库都使用warehouse_id
                warehouseInOutRecord.warehouse_id = planTaskBatchDetail.warehouse_id;
                warehouseInOutRecord.grain_kind   = planTaskBatch.PlanTask.goods_kind.Value;

                if (planTaskBatch.PlanTask.Enrolment == null)
                {
                    warehouseInOutRecord.record_type = (int)RecordType.入库;
                    if (warehouseInOutRecord.balance_count == null)
                    {
                        warehouseInOutRecord.balance_count = planTaskBatchDetail.weight;
                    }
                    else
                    {
                        warehouseInOutRecord.balance_count += planTaskBatchDetail.weight;
                    }
                }
                else
                {
                    if (planTaskBatch.PlanTask.Enrolment.inout_type == (int)InOutType.入库)
                    {
                        warehouseInOutRecord.record_type = (int)RecordType.入库;
                        if (warehouseInOutRecord.balance_count == null)
                        {
                            warehouseInOutRecord.balance_count = planTaskBatchDetail.weight;
                        }
                        else
                        {
                            warehouseInOutRecord.balance_count += planTaskBatchDetail.weight;
                        }
                    }
                    else
                    {
                        warehouseInOutRecord.record_type    = (int)RecordType.出库;
                        warehouseInOutRecord.balance_count -= planTaskBatchDetail.weight;
                    }
                }
            }
            else
            {
                //记录倒仓仓号
                warehouseInOutRecord.warehouse_id   = planTaskBatchDetail.outwarehouse;
                warehouseInOutRecord.grain_kind     = warehouseStoreInfo.grain_kind;
                warehouseInOutRecord.record_type    = (int)RecordType.出库;
                warehouseInOutRecord.balance_count -= planTaskBatchDetail.weight;
            }
            warehouseInOutRecord.warehouse_store_info = warehouseStoreInfo.warehouse_store_id;
            warehouseInOutRecord.work_plan            = planTaskBatch.plantask_batch_number;
            warehouseInOutRecord.inout_datetime       = planTaskBatchDetail.weight_time == null ? "" : planTaskBatchDetail.weight_time.Value.ToString("yyyyMMddHHmmss");
            warehouseInOutRecord.inout_finished       = true;
            warehouseInOutRecord.location_flag        = false;
            warehouseInOutRecord.manual_registe       = false;
            warehouseInOutRecord.record_count         = planTaskBatchDetail.weight;

            if (isOutInFlag)
            {
                if (isOutWarehouseStoreInfo)
                {
                    warehouseInOutRecord.record_type = (int)RecordType.倒仓出库;
                }
                else
                {
                    warehouseInOutRecord.record_type = (int)RecordType.倒仓入库;
                }
            }

            _unitOfWork.AddAction(warehouseInOutRecord, DAL.Enums.DataActions.Add);

            return(warehouseInOutRecord);
        }