Ejemplo n.º 1
0
 public static AscmWmsPreparationDetailService GetInstance()
 {
     if (service == null)
     {
         service = new AscmWmsPreparationDetailService();
     }
     return(service);
 }
 public static AscmWmsPreparationDetailService GetInstance()
 {
     if (service == null)
         service = new AscmWmsPreparationDetailService();
     return service;
 }
Ejemplo n.º 3
0
        /// <summary>需求备料平台</summary>
        public List <AscmWmsWipRequireLedMonitor> GetWipRequireLedMonitorList()
        {
            List <AscmWmsWipRequireLedMonitor> listWipRequireLedMonitorList = new List <AscmWmsWipRequireLedMonitor>();
            //获取当天需求备料明细
            string hql = "select new AscmWmsPreparationDetail(d.materialId,m.docNumber,d.planQuantity,d.issueQuantity,d.wipEntityId,w.name) from AscmWmsPreparationDetail d,AscmMaterialItem m,AscmWipEntities w";

            string where = string.Empty;
            where        = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "d.materialId=m.id");
            where        = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "d.wipEntityId=w.wipEntityId");
            where        = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "d.mainId in(select id from AscmWmsPreparationMain where pattern='" + AscmWmsPreparationMain.PatternDefine.wipRequire + "')");
            where        = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "d.createTime>='" + DateTime.Now.ToString("yyyy-MM-dd 00:00:00") + "'");
            where        = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "d.createTime<'" + DateTime.Now.AddDays(1).ToString("yyyy-MM-dd 00:00:00") + "'");
            where        = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "d.warehouseId in('W112材料','W114材料','W312材料')");
            hql         += " where " + where;
            List <AscmWmsPreparationDetail> listPreparationDetail = AscmWmsPreparationDetailService.GetInstance().GetList(hql);

            if (listPreparationDetail != null && listPreparationDetail.Count > 0)
            {
                //取物流领料模块数据
                hql   = "select new AscmWipRequirementOperations(o.wipEntityId,o.inventoryItemId,t.workerId,t.productLine) from AscmWipRequirementOperations o,AscmGetMaterialTask t";
                where = string.Empty;
                string _where = string.Empty;
                where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "o.taskId=t.id");
                var result = listPreparationDetail.GroupBy(P => P.wipEntityId);
                foreach (IGrouping <int, AscmWmsPreparationDetail> ig in result)
                {
                    string whereOther  = string.Empty;
                    var    materialIds = ig.Select(P => P.materialId).Distinct();
                    var    count       = materialIds.Count();
                    string ids         = string.Empty;
                    for (int i = 0; i < count; i++)
                    {
                        if (!string.IsNullOrEmpty(ids))
                        {
                            ids += ",";
                        }
                        ids += materialIds.ElementAt(i);
                        if ((i + 1) % 500 == 0 || (i + 1) == count)
                        {
                            if (!string.IsNullOrEmpty(ids))
                            {
                                whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereOrAdd(whereOther, "o.inventoryItemId in(" + ids + ")");
                            }
                            ids = string.Empty;
                        }
                    }
                    _where = YnBaseClass2.Helper.StringHelper.SqlWhereOrAdd(_where, "o.wipEntityId=" + ig.Key + " and (" + whereOther + ")");
                }
                where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, _where);
                hql  += " where " + where;
                List <MideaAscm.Dal.FromErp.Entities.AscmWipRequirementOperations> listBom = MideaAscm.Services.FromErp.AscmWipRequirementOperationsService.GetInstance().GetList(hql);

                //按物料分组统计
                var gb = listPreparationDetail.GroupBy(P => P.materialId);
                foreach (IGrouping <int, AscmWmsPreparationDetail> ig in gb)
                {
                    string materialDocNumber = ig.FirstOrDefault().materialDocNumber;
                    AscmWmsWipRequireLedMonitor wipRequireLedMonitor = new AscmWmsWipRequireLedMonitor();
                    wipRequireLedMonitor.materialDocNumber = materialDocNumber;
                    wipRequireLedMonitor.netQuantity       = ig.Sum(P => P.planQuantity);
                    wipRequireLedMonitor.issuedQuantity    = ig.Sum(P => P.issueQuantity);
                    if (listBom != null && listBom.Count > 0)
                    {
                        var _listBom = listBom.Where(P => P.inventoryItemId == ig.Key && ig.Select(T => T.wipEntityId).Contains(P.wipEntityId));
                        if (_listBom != null && _listBom.Count() > 0)
                        {
                            wipRequireLedMonitor.workerId       = string.Join("、", _listBom.Select(P => P.workerId));
                            wipRequireLedMonitor.productionLine = string.Join("、", _listBom.Select(P => P.productLine));
                        }
                    }
                    listWipRequireLedMonitorList.Add(wipRequireLedMonitor);
                }
            }

            return(listWipRequireLedMonitorList);
        }