Esempio n. 1
0
 public EditTask(AscmGetMaterialTask task)
 {
     editTask = task;
     InitializeComponent();
     InitializeComponentValue();
     InitializeTaskModel();
 }
Esempio n. 2
0
        /// <summary>
        /// 任务编辑
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnTaskEdit_Click(object sender, EventArgs e)
        {
            if (dataGridViewTasks.SelectedRows == null || dataGridViewTasks.SelectedRows.Count == 0)
            {
                MessageBoxEx.Show("请先选中要修改的数据行!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                AscmGetMaterialTask task = new AscmGetMaterialTask();
                task.id = int.Parse((dataGridViewTasks.SelectedRows[0].Cells["ID"].Value == null) ? string.Empty : dataGridViewTasks.SelectedRows[0].Cells["ID"].Value.ToString());
                task.productLine = (dataGridViewTasks.SelectedRows[0].Cells["productLine"].Value == null) ? string.Empty : dataGridViewTasks.SelectedRows[0].Cells["productLine"].Value.ToString();
                task.warehouserId = (dataGridViewTasks.SelectedRows[0].Cells["warehouserId"].Value == null) ? string.Empty : dataGridViewTasks.SelectedRows[0].Cells["warehouserId"].Value.ToString();
                task.mtlCategoryStatus = (dataGridViewTasks.SelectedRows[0].Cells["mtlCategoryStatus"].Value == null) ? string.Empty : dataGridViewTasks.SelectedRows[0].Cells["mtlCategoryStatus"].Value.ToString();
                task.rankerId = (dataGridViewTasks.SelectedRows[0].Cells["rankerId"].Value == null) ? string.Empty : dataGridViewTasks.SelectedRows[0].Cells["rankerId"].Value.ToString();
                task.IdentificationId = int.Parse((dataGridViewTasks.SelectedRows[0].Cells["IdentificationId"].Value == null) ? string.Empty : dataGridViewTasks.SelectedRows[0].Cells["IdentificationId"].Value.ToString());
                task.materialDocNumber = (dataGridViewTasks.SelectedRows[0].Cells["materialDocNumber"].Value == null) ? string.Empty : dataGridViewTasks.SelectedRows[0].Cells["materialDocNumber"].Value.ToString();
                task.taskTime = (dataGridViewTasks.SelectedRows[0].Cells["taskTime"].Value == null) ? string.Empty : dataGridViewTasks.SelectedRows[0].Cells["taskTime"].Value.ToString();
                task.tip = (dataGridViewTasks.SelectedRows[0].Cells["tip"].Value == null) ? string.Empty : dataGridViewTasks.SelectedRows[0].Cells["tip"].Value.ToString();
                task.workerId = (dataGridViewTasks.SelectedRows[0].Cells["workerId"].Value == null) ? string.Empty : dataGridViewTasks.SelectedRows[0].Cells["workerId"].Value.ToString();

                WinForm.Task.EditTask Form = new WinForm.Task.EditTask(task);
                Form.refreshHandler += btnTasksSearch_Click;
                Form.ShowDialog();
            }
        }
Esempio n. 3
0
        public ContentResult AllocateLogisticsTaskEditSave(AscmGetMaterialTask ascmGetMaterialTask_Model, int? id)
        {
            JsonObjectResult jsonObjectResult = new JsonObjectResult();

            string userName = string.Empty;
            if (User.Identity.IsAuthenticated)
            {
                userName = User.Identity.Name;
            }
            try
            {

                if (id.HasValue)
                {
                    AscmGetMaterialTask ascmGetMaterialTask = AscmGetMaterialTaskService.GetInstance().Get(ascmGetMaterialTask_Model.id);
                    if (ascmGetMaterialTask.taskId.Substring(0, 1) == AscmCommonHelperService.GetInstance().GetConfigTaskWords(0))
                    {
                        string ids = string.Empty;
                        if (!string.IsNullOrEmpty(ascmGetMaterialTask.workerId))
                            ids += "'" + ascmGetMaterialTask.workerId + "'";
                        if (!string.IsNullOrEmpty(ids) && !string.IsNullOrEmpty(ascmGetMaterialTask_Model.WorkerName))
                            ids += ",";
                        if (!string.IsNullOrEmpty(ascmGetMaterialTask_Model.WorkerName))
                            ids += "'" + ascmGetMaterialTask_Model.WorkerName + "'";

                        string whereOther = "", whereQueryWord = "";
                        whereQueryWord = "workerName in (" + ids + ")";
                        whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereQueryWord);

                        List<AscmAllocateRule> list = AscmAllocateRuleService.GetInstance().GetList(null, "", "", "", whereOther);
                        if (list != null && list.Count > 0)
                        {
                            foreach (AscmAllocateRule ascmAllocateRule in list)
                            {
                                if (ascmAllocateRule.workerName == ascmGetMaterialTask.workerId)
                                {
                                    ascmAllocateRule.taskCount++;
                                }
                                else if (ascmAllocateRule.workerName == ascmGetMaterialTask_Model.WorkerName)
                                {
                                    ascmAllocateRule.taskCount--;
                                }
                                ascmAllocateRule.modifyUser = userName;
                                ascmAllocateRule.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                            }
                        }

                        AscmAllocateRuleService.GetInstance().Update(list);
                    }
                    if (!string.IsNullOrEmpty(ascmGetMaterialTask_Model.WorkerName))
                    {
                        ascmGetMaterialTask.workerId = ascmGetMaterialTask_Model.WorkerName;
                        ascmGetMaterialTask.status = "NOTEXECUTE";
                        AscmGetMaterialTaskService.GetInstance().Update(ascmGetMaterialTask);
                    }
                }

                jsonObjectResult.result = true;
                jsonObjectResult.message = "";
            }
            catch (Exception ex)
            {
                jsonObjectResult.result = false;
                jsonObjectResult.message = ex.Message;
            }

            string sReturn = JsonConvert.SerializeObject(jsonObjectResult);
            return Content(sReturn);
        }
Esempio n. 4
0
        public ContentResult AllocateLogisticsTaskAddSave(AscmGetMaterialTask ascmGetMaterialTask_Model, string warehouserPlace)
        {
            JsonObjectResult jsonObjectResult = new JsonObjectResult();
            AscmGetMaterialTask ascmGetMaterialTask = null;
            AscmMarkTaskLog ascmMarkTaskLog = null;

            string userName = string.Empty;
            if (User.Identity.IsAuthenticated)
            {
                userName = User.Identity.Name;
            }

            try
            {
                string userRole = AscmUserInfoService.GetInstance().GetUserRoleName(userName);
                string userLogisticsClass = AscmUserInfoService.GetInstance().GetUserLogisticsName(userName);

                if (string.IsNullOrEmpty(ascmGetMaterialTask_Model.tip) || string.IsNullOrEmpty(ascmGetMaterialTask_Model.warehouserId))
                    throw new Exception("作业内容或子库不能为空!");
                int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmGetMaterialTask where TaskId like '%L%' AND CREATETIME like '%" + DateTime.Now.ToString("yyyy-MM-dd") + "%'");
                ascmGetMaterialTask_Model.taskId = (maxId == 0) ? "L1001" : "L" + (int.Parse(AscmGetMaterialTaskService.GetInstance().Get(maxId).taskId.Substring(1, 4)) + 1).ToString();
                ascmGetMaterialTask_Model.id = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmGetMaterialTask ") + 1;
                ascmGetMaterialTask_Model.createUser = userName;
                ascmGetMaterialTask_Model.modifyUser = userName;
                ascmGetMaterialTask_Model.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                ascmGetMaterialTask_Model.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");

                if (!string.IsNullOrEmpty(userRole) && userRole.IndexOf("领料员") > -1)
                {
                    ascmGetMaterialTask_Model.workerId = userName;
                    ascmGetMaterialTask_Model.logisticsClass = userLogisticsClass;
                    ascmGetMaterialTask_Model.status = AscmGetMaterialTask.StatusDefine.notExecute;
                }
                else
                {
                    ascmGetMaterialTask_Model.status = AscmGetMaterialTask.StatusDefine.notAllocate;
                }

                ascmGetMaterialTask_Model.materialType = 1;
                ascmGetMaterialTask_Model.uploadDate = DateTime.Now.ToString("yyyy-MM-dd");
                ascmGetMaterialTask_Model.which = 1;

                if (!string.IsNullOrEmpty(ascmGetMaterialTask_Model.relatedMarkId.ToString()) && ascmGetMaterialTask_Model.relatedMarkId > 0)
                {
                    ascmMarkTaskLog = AscmMarkTaskLogService.GetInstance().Get(ascmGetMaterialTask_Model.relatedMarkId);
                    if (ascmMarkTaskLog != null)
                    {
                        ascmMarkTaskLog.isMark = 0;
                        ascmMarkTaskLog.modifyUser = userName;
                        ascmMarkTaskLog.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");

                    }
                    ascmGetMaterialTask_Model.relatedMark += ascmGetMaterialTask_Model.relatedMarkId.ToString();
                }

                ascmGetMaterialTask = AscmGetMaterialTaskService.GetInstance().Get(ascmMarkTaskLog.taskId);
                if (!string.IsNullOrEmpty(ascmGetMaterialTask.relatedMark))
                {
                    if (ascmGetMaterialTask.relatedMark.IndexOf(',') > -1)
                    {
                        if (ascmGetMaterialTask.relatedMark.IndexOf(ascmMarkTaskLog.id.ToString()) > -1)
                        {
                            ascmGetMaterialTask.relatedMark = ascmGetMaterialTask.relatedMark.Replace(ascmMarkTaskLog.id.ToString(), "");
                            string[] stringArray = ascmGetMaterialTask.relatedMark.Split(',');
                            string stringRelatedMark = "";
                            foreach (string item in stringArray)
                            {
                                if (!string.IsNullOrEmpty(item))
                                    stringRelatedMark += ",";
                                stringRelatedMark += item;
                            }
                            ascmGetMaterialTask.relatedMark = stringRelatedMark;
                        }
                    }
                    else
                    {
                        if (ascmGetMaterialTask.relatedMark == ascmMarkTaskLog.id.ToString())
                            ascmGetMaterialTask.relatedMark = null;
                    }
                }

                //保存临时任务
                if (ascmGetMaterialTask_Model != null)
                    AscmGetMaterialTaskService.GetInstance().Save(ascmGetMaterialTask_Model);

                //修改标记任务
                if (ascmGetMaterialTask != null)
                    AscmGetMaterialTaskService.GetInstance().Update(ascmGetMaterialTask);

                //修改关联标记
                if(ascmMarkTaskLog != null)
                AscmMarkTaskLogService.GetInstance().Update(ascmMarkTaskLog);

                jsonObjectResult.result = true;
                jsonObjectResult.message = "";
            }
            catch (Exception ex)
            {
                jsonObjectResult.result = false;
                jsonObjectResult.message = ex.Message;
            }

            string sReturn = JsonConvert.SerializeObject(jsonObjectResult);
            return Content(sReturn);
        }
Esempio n. 5
0
        //判断规则及指定关系人
        public bool IsJudgeCodeAndRanker(AscmGenerateTaskRule ascmGenerateTaskRule, AscmGetMaterialTask ascmGetMaterialTask, string warehouseId, string docnumber, bool isRule, bool isRaner)
        {
            if (!string.IsNullOrEmpty(ascmGenerateTaskRule.ruleCode))
            {
                string[] myArray = ascmGenerateTaskRule.ruleCode.Split('&');
                string warehouseString = myArray[0].Substring(myArray[0].IndexOf("(") + 1, myArray[0].IndexOf(")") - myArray[0].IndexOf("(") - 1);
                string materialString = myArray[1].Substring(myArray[1].IndexOf("(") + 1, myArray[1].IndexOf(")") - myArray[1].IndexOf("(") - 1);

                if (warehouseString.Length > 0 && warehouseString.IndexOf(warehouseId) > -1)
                {
                    #region
                    if (materialString.Length > 0)
                    {
                        if (materialString.IndexOf("|") > -1)
                        {
                            string[] mtlArray = materialString.Split('|');
                            foreach (string mtl in mtlArray)
                            {
                                if (mtl.IndexOf(warehouseId) > -1)
                                {
                                    string material = mtl.Substring(mtl.IndexOf(":") + 1, mtl.Length - mtl.IndexOf(":") - 1);
                                    if (material.IndexOf("%") > -1)
                                    {
                                        string[] materialArray = material.Split('%');
                                        foreach (string item in materialArray)
                                        {
                                            if (item == docnumber.Substring(0, item.Length))
                                            {
                                                isRule = true;
                                                break;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (material == docnumber.Substring(0, material.Length))
                                        {
                                            isRule = true;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (materialString.IndexOf(warehouseId) > -1)
                            {
                                string material = materialString.Substring(materialString.IndexOf(":") + 1, materialString.Length - materialString.IndexOf(":") - 1);
                                if (material.IndexOf("%") > -1)
                                {
                                    string[] materialArray = material.Split('%');
                                    foreach (string item in materialArray)
                                    {
                                        if (item == docnumber.Substring(0, item.Length))
                                        {
                                            isRule = true;
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    if (material == docnumber.Substring(0, material.Length))
                                    {
                                        isRule = true;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        isRule = true;
                    }
                    #endregion
                }
            }
            else
            {
                isRule = true;
            }

            if (!string.IsNullOrEmpty(ascmGenerateTaskRule.relatedRanker))
            {
                if (ascmGenerateTaskRule.relatedRanker == ascmGetMaterialTask.rankerId)
                    isRaner = true;
            }
            else
            {
                isRaner = true;
            }

            return (isRule && isRaner);
        }
Esempio n. 6
0
        public ActionResult GetWorkerTaskCountList(string queryStartTime, string queryEndTime, string queryLogisticsClass)
        {
            List<AscmGetMaterialTask> list = new List<AscmGetMaterialTask>(); ;
            JsonDataGridResult jsonDataGridResult = new JsonDataGridResult();

            string userName = string.Empty;
            string userRole = string.Empty;
            string userLogistisClass = string.Empty;
            if (User.Identity.IsAuthenticated)
            {
                userName = User.Identity.Name;
            }
            userRole = AscmUserInfoService.GetInstance().GetUserRoleName(userName);
            userLogistisClass = AscmUserInfoService.GetInstance().GetUserLogisticsName(userName, userRole);

            try
            {
                string sql = "select workerId, count(workerId),round(avg(round(to_number(to_date(endTime,'yyyy-mm-dd hh24:mi:ss')- to_date(starTime,'yyyy-mm-dd hh24:mi:ss'))*1440))) from Ascm_Getmaterial_Task";
                string where = "", whereQueryWord = "", groupString = "", orderString = "";
                groupString = " group by workerId";
                orderString = " order by workerId";
                whereQueryWord = "workerId is not null";
                where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                whereQueryWord = "status = 'FINISH'";
                where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);

                if (!string.IsNullOrEmpty(userLogistisClass))
                {
                    whereQueryWord = "logisticsClass in (" + userLogistisClass + ")";
                    where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                }

                if (string.IsNullOrEmpty(queryStartTime) && string.IsNullOrEmpty(queryEndTime))
                    throw new Exception("查询统计:开始日期或结束日期至少一个不为空!");

                if (!string.IsNullOrEmpty(queryStartTime))
                {
                    string sTime = queryStartTime + " 00:00";
                    whereQueryWord = "starTime >= '" + sTime + "'";
                    where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                }

                if (!string.IsNullOrEmpty(queryEndTime))
                {
                    string eTime = queryEndTime + " 23:59";
                    whereQueryWord = "endTime <= '" + eTime + "'";
                    where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                }

                if (!string.IsNullOrEmpty(queryLogisticsClass))
                {
                    whereQueryWord = "logisticsClass = '" + userLogistisClass + "'";
                    where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                }

                if (!string.IsNullOrEmpty(where))
                    sql += " where " + where + groupString + orderString;
                IList ilist = YnDaoHelper.GetInstance().nHibernateHelper.ExecuteReader(sql);
                if (ilist != null && ilist.Count > 0)
                {
                    foreach (object[] obj in ilist)
                    {
                        AscmGetMaterialTask ascmGetMaterialTask = new AscmGetMaterialTask();
                        ascmGetMaterialTask.workerId = obj[0].ToString();
                        ascmGetMaterialTask.taskCount = obj[1].ToString();
                        ascmGetMaterialTask.avgTime = obj[2].ToString();
                        list.Add(ascmGetMaterialTask);
                    }
                }

                if (list != null && list.Count > 0)
                {
                    AscmGetMaterialTaskService.GetInstance().SetWorker(list);

                    foreach (AscmGetMaterialTask ascmGetMaterialTask in list)
                    {
                        jsonDataGridResult.rows.Add(ascmGetMaterialTask);
                    }
                }
                jsonDataGridResult.result = true;
            }
            catch (Exception ex)
            {
                jsonDataGridResult.result = false;
                jsonDataGridResult.message = ex.Message;
            }

            return Json(jsonDataGridResult, JsonRequestBehavior.AllowGet);
        }
Esempio n. 7
0
        //生成任务
        public List<AscmGetMaterialTask> GenerateTask(List<AscmWipRequirementOperations> list, string generateTaskDate)
        {
            List<AscmGetMaterialTask> listTask = new List<AscmGetMaterialTask>();

            try
            {
                List<AscmGenerateTaskRule> list_rule = AscmGenerateTaskRuleService.GetInstance().GetList(null, "identificationId,priority", "", "", "");
                if (list_rule == null || list_rule.Count == 0)
                    throw new Exception("生成领料任务规则不存在!");

                generateTaskDate = Convert.ToDateTime(generateTaskDate).ToString("yyyy-MM-dd");
                int iCount = YnDaoHelper.GetInstance().nHibernateHelper.GetCount("select count(*) from AscmGetMaterialTask where uploadDate = '" + generateTaskDate + "'");

                foreach (AscmWipRequirementOperations ascmWipRequirmentOperations in list)
                {
                    foreach (AscmGenerateTaskRule ascmGenerateTaskRule in list_rule)
                    {
                        AscmGetMaterialTask ascmGetMaterialTask = new AscmGetMaterialTask();
                        ascmGetMaterialTask.taskId = AscmCommonHelperService.GetInstance().getTaskId(iCount + listTask.Count + 1);
                        ascmGetMaterialTask.productLine = ascmWipRequirmentOperations.productLine;
                        ascmGetMaterialTask.IdentificationId = ascmWipRequirmentOperations.identificationId;
                        ascmGetMaterialTask.warehouserId = ascmWipRequirmentOperations.supplySubinventory;
                        ascmGetMaterialTask.materialDocNumber = ascmWipRequirmentOperations.docNumber;
                        ascmGetMaterialTask.materialType = ascmWipRequirmentOperations.wipSupplyType;
                        ascmGetMaterialTask.dateReleased = ascmWipRequirmentOperations.jobDate;

                        switch (ascmGetMaterialTask.IdentificationId)
                        {
                            case 1://总装
                                ascmGetMaterialTask.mtlCategoryStatus = ascmWipRequirmentOperations.zMtlCategoryStatus;
                                break;
                            case 2://电装
                                ascmGetMaterialTask.mtlCategoryStatus = ascmWipRequirmentOperations.dMtlCategoryStatus;
                                break;
                        }
                        ascmGetMaterialTask.uploadDate = generateTaskDate;
                        ascmGetMaterialTask.which = ascmWipRequirmentOperations.which;
                        ascmGetMaterialTask.rankerId = ascmWipRequirmentOperations.workerId;
                        ascmGetMaterialTask.taskTime = ascmWipRequirmentOperations.onlineTime;
                        ascmGetMaterialTask.status = AscmGetMaterialTask.StatusDefine.notAllocate;

                        if (ascmGenerateTaskRule.identificationId == ascmGetMaterialTask.IdentificationId)
                        {
                            if (string.IsNullOrEmpty(ascmWipRequirmentOperations.supplySubinventory))
                            {
                                continue;
                            }

                            string warehouseId = ascmWipRequirmentOperations.supplySubinventory.Substring(0, 4);
                            string docnumber = ascmWipRequirmentOperations.docNumber;
                            switch (ascmGenerateTaskRule.ruleType)
                            {
                                case AscmGenerateTaskRule.RuleTypeDefine.typeofPreStock:
                                    {
                                        if (ascmGetMaterialTask.mtlCategoryStatus == MtlCategoryStatusDefine.preStock)
                                        {
                                            bool isOk = IsJudgeCodeAndRanker(ascmGenerateTaskRule, ascmGetMaterialTask, warehouseId, docnumber, false, false);

                                            if (isOk)
                                            {
                                                ascmGetMaterialTask.ruleType = ascmGenerateTaskRule.ruleType;
                                                // 任务不存在
                                                if (ContainsTask(listTask, ascmGetMaterialTask) == null)
                                                {
                                                    if (ascmGetMaterialTask.listAscmWipRequirementOperations == null)
                                                        ascmGetMaterialTask.listAscmWipRequirementOperations = new List<AscmWipRequirementOperations>();
                                                    ascmGetMaterialTask.listAscmWipRequirementOperations.Add(ascmWipRequirmentOperations);

                                                    listTask.Add(ascmGetMaterialTask);
                                                }
                                                else
                                                {
                                                    //任务存在,判断是否包含该BOM
                                                    AscmGetMaterialTask task = ContainsTask(listTask, ascmGetMaterialTask);
                                                    if (ContainsOperations(task.listAscmWipRequirementOperations, ascmWipRequirmentOperations) == null)
                                                    {
                                                        task.listAscmWipRequirementOperations.Add(ascmWipRequirmentOperations);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    break;
                                case AscmGenerateTaskRule.RuleTypeDefine.typeofMixStock:
                                    {
                                        if (ascmGetMaterialTask.mtlCategoryStatus == MtlCategoryStatusDefine.mixStock)
                                        {
                                            bool isOk = IsJudgeCodeAndRanker(ascmGenerateTaskRule, ascmGetMaterialTask, warehouseId, docnumber, false, false);

                                            if (isOk)
                                            {
                                                ascmGetMaterialTask.ruleType = ascmGenerateTaskRule.ruleType;
                                                // 任务不存在
                                                if (ContainsTask(listTask, ascmGetMaterialTask) == null)
                                                {
                                                    if (ascmGetMaterialTask.listAscmWipRequirementOperations == null)
                                                        ascmGetMaterialTask.listAscmWipRequirementOperations = new List<AscmWipRequirementOperations>();
                                                    ascmGetMaterialTask.listAscmWipRequirementOperations.Add(ascmWipRequirmentOperations);

                                                    ascmGetMaterialTask.materialDocNumber = "";
                                                    listTask.Add(ascmGetMaterialTask);
                                                }
                                                else
                                                {
                                                    //任务存在,判断是否包含该BOM
                                                    AscmGetMaterialTask task = ContainsTask(listTask, ascmGetMaterialTask);
                                                    if (ContainsOperations(task.listAscmWipRequirementOperations, ascmWipRequirmentOperations) == null)
                                                    {
                                                        task.listAscmWipRequirementOperations.Add(ascmWipRequirmentOperations);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    break;
                                case AscmGenerateTaskRule.RuleTypeDefine.typeofWarehouse:
                                    {
                                        bool isOk = IsJudgeCodeAndRanker(ascmGenerateTaskRule, ascmGetMaterialTask, warehouseId, docnumber, false, false);

                                        if (isOk)
                                        {
                                            ascmGetMaterialTask.ruleType = ascmGenerateTaskRule.ruleType;
                                            // 任务不存在
                                            if (ContainsTask(listTask, ascmGetMaterialTask) == null)
                                            {
                                                if (ascmGetMaterialTask.listAscmWipRequirementOperations == null)
                                                    ascmGetMaterialTask.listAscmWipRequirementOperations = new List<AscmWipRequirementOperations>();
                                                ascmGetMaterialTask.listAscmWipRequirementOperations.Add(ascmWipRequirmentOperations);

                                                ascmGetMaterialTask.mtlCategoryStatus = "";
                                                ascmGetMaterialTask.materialDocNumber = "";
                                                listTask.Add(ascmGetMaterialTask);
                                            }
                                            else
                                            {
                                                //任务存在,判断是否包含该BOM
                                                AscmGetMaterialTask task = ContainsTask(listTask, ascmGetMaterialTask);
                                                if (ContainsOperations(task.listAscmWipRequirementOperations, ascmWipRequirmentOperations) == null)
                                                {
                                                    task.listAscmWipRequirementOperations.Add(ascmWipRequirmentOperations);
                                                }
                                            }
                                        }
                                    }
                                    break;
                                case AscmGenerateTaskRule.RuleTypeDefine.typeofMaterial:
                                    {
                                        bool isOk = IsJudgeCodeAndRanker(ascmGenerateTaskRule, ascmGetMaterialTask, warehouseId, docnumber, false, false);

                                        if (isOk)
                                        {
                                            ascmGetMaterialTask.ruleType = ascmGenerateTaskRule.ruleType;
                                            // 任务不存在
                                            if (ContainsTask(listTask, ascmGetMaterialTask) == null)
                                            {
                                                if (ascmGetMaterialTask.listAscmWipRequirementOperations == null)
                                                    ascmGetMaterialTask.listAscmWipRequirementOperations = new List<AscmWipRequirementOperations>();
                                                ascmGetMaterialTask.listAscmWipRequirementOperations.Add(ascmWipRequirmentOperations);

                                                listTask.Add(ascmGetMaterialTask);
                                            }
                                            else
                                            {
                                                //任务存在,判断是否包含该BOM
                                                AscmGetMaterialTask task = ContainsTask(listTask, ascmGetMaterialTask);
                                                if (ContainsOperations(task.listAscmWipRequirementOperations, ascmWipRequirmentOperations) == null)
                                                {
                                                    task.listAscmWipRequirementOperations.Add(ascmWipRequirmentOperations);
                                                }
                                            }
                                        }
                                    }
                                    break;
                                case AscmGenerateTaskRule.RuleTypeDefine.typeofProductLine:
                                    {
                                        bool isOk = IsJudgeCodeAndRanker(ascmGenerateTaskRule, ascmGetMaterialTask, warehouseId, docnumber, false, false);

                                        if (isOk)
                                        {
                                            ascmGetMaterialTask.ruleType = ascmGenerateTaskRule.ruleType;
                                            // 任务不存在
                                            if (ContainsTask(listTask, ascmGetMaterialTask) == null)
                                            {
                                                if (ascmGetMaterialTask.listAscmWipRequirementOperations == null)
                                                    ascmGetMaterialTask.listAscmWipRequirementOperations = new List<AscmWipRequirementOperations>();
                                                ascmGetMaterialTask.listAscmWipRequirementOperations.Add(ascmWipRequirmentOperations);

                                                ascmGetMaterialTask.materialDocNumber = "";
                                                listTask.Add(ascmGetMaterialTask);
                                            }
                                            else
                                            {
                                                //任务存在,判断是否包含该BOM
                                                AscmGetMaterialTask task = ContainsTask(listTask, ascmGetMaterialTask);
                                                if (ContainsOperations(task.listAscmWipRequirementOperations, ascmWipRequirmentOperations) == null)
                                                {
                                                    task.listAscmWipRequirementOperations.Add(ascmWipRequirmentOperations);
                                                }
                                            }
                                        }
                                    }
                                    break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                YnBaseClass2.Helper.LogHelper.GetLog().Error("生成任务失败(Generate GetMaterialTask) ", ex);
                throw ex;
            }

            return listTask;
        }
Esempio n. 8
0
        //判断是否包含任务
        public AscmGetMaterialTask ContainsTask(List<AscmGetMaterialTask> listTask, AscmGetMaterialTask ascmGetMaterialTask)
        {
            if (listTask.Count == 0)
                return null;

            switch (ascmGetMaterialTask.ruleType)
            {
                case AscmGenerateTaskRule.RuleTypeDefine.typeofPreStock:
                    {
                        foreach (AscmGetMaterialTask item in listTask)
                        {
                            if (item.rankerId == ascmGetMaterialTask.rankerId && item.uploadDate == ascmGetMaterialTask.uploadDate && item.IdentificationId == ascmGetMaterialTask.IdentificationId && item.warehouserId == ascmGetMaterialTask.warehouserId && item.materialDocNumber == ascmGetMaterialTask.materialDocNumber && item.mtlCategoryStatus == ascmGetMaterialTask.mtlCategoryStatus && item.productLine == ascmGetMaterialTask.productLine && item.taskTime == ascmGetMaterialTask.taskTime && item.which == ascmGetMaterialTask.which && item.dateReleased == ascmGetMaterialTask.dateReleased)
                                return item;
                        }
                    }
                    break;
                case AscmGenerateTaskRule.RuleTypeDefine.typeofMixStock:
                    {
                        foreach (AscmGetMaterialTask item in listTask)
                        {
                            if (item.rankerId == ascmGetMaterialTask.rankerId && item.uploadDate == ascmGetMaterialTask.uploadDate && item.IdentificationId == ascmGetMaterialTask.IdentificationId && item.warehouserId == ascmGetMaterialTask.warehouserId && item.mtlCategoryStatus == ascmGetMaterialTask.mtlCategoryStatus && item.productLine == ascmGetMaterialTask.productLine && item.taskTime == ascmGetMaterialTask.taskTime && item.which == ascmGetMaterialTask.which && item.dateReleased == ascmGetMaterialTask.dateReleased)
                                return item;
                        }
                    }
                    break;
                case AscmGenerateTaskRule.RuleTypeDefine.typeofWarehouse:
                    {
                        foreach (AscmGetMaterialTask item in listTask)
                        {
                            if (item.rankerId == ascmGetMaterialTask.rankerId && item.uploadDate == ascmGetMaterialTask.uploadDate && item.IdentificationId == ascmGetMaterialTask.IdentificationId && item.warehouserId == ascmGetMaterialTask.warehouserId && item.productLine == ascmGetMaterialTask.productLine && item.taskTime == ascmGetMaterialTask.taskTime && item.which == ascmGetMaterialTask.which && item.dateReleased == ascmGetMaterialTask.dateReleased)
                                return item;
                        }
                    }
                    break;
                case AscmGenerateTaskRule.RuleTypeDefine.typeofMaterial:
                    {
                        foreach (AscmGetMaterialTask item in listTask)
                        {
                            if (item.rankerId == ascmGetMaterialTask.rankerId && item.uploadDate == ascmGetMaterialTask.uploadDate && item.IdentificationId == ascmGetMaterialTask.IdentificationId && item.warehouserId == ascmGetMaterialTask.warehouserId && item.productLine == ascmGetMaterialTask.productLine && item.taskTime == ascmGetMaterialTask.taskTime && item.materialDocNumber == ascmGetMaterialTask.materialDocNumber && item.which == ascmGetMaterialTask.which && item.dateReleased == ascmGetMaterialTask.dateReleased)
                                return item;
                        }
                    }
                    break;
                case AscmGenerateTaskRule.RuleTypeDefine.typeofProductLine:
                    {
                        foreach (AscmGetMaterialTask item in listTask)
                        {
                            if (item.rankerId == ascmGetMaterialTask.rankerId && item.uploadDate == ascmGetMaterialTask.uploadDate && item.IdentificationId == ascmGetMaterialTask.IdentificationId && item.warehouserId == ascmGetMaterialTask.warehouserId && item.productLine == ascmGetMaterialTask.productLine && item.taskTime == ascmGetMaterialTask.taskTime && item.which == ascmGetMaterialTask.which && item.dateReleased == ascmGetMaterialTask.dateReleased)
                                return item;
                        }
                    }
                    break;

            }

            return null;
        }
 public void Delete(AscmGetMaterialTask ascmGetMaterialTask)
 {
     try
     {
         YnDaoHelper.GetInstance().nHibernateHelper.Delete<AscmGetMaterialTask>(ascmGetMaterialTask);
     }
     catch (Exception ex)
     {
         YnBaseClass2.Helper.LogHelper.GetLog().Error("删除失败(Delete AscmGetMaterialTask)", ex);
         throw ex;
     }
 }
Esempio n. 10
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(cbWarehouse.Text) || string.IsNullOrEmpty(cbTipCn.SelectedItem.ToString()))
                {
                    MessageBoxEx.Show("信息填写不完整:请填写仓库及作业内容!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                string queryType = string.Empty;
                if (cbTaskType.SelectedItem != null)
                {
                    switch (cbTaskType.SelectedItem.ToString())
                    {
                        case "总装":
                            queryType = "1";
                            break;
                        case "电装":
                            queryType = "2";
                            break;
                        default:
                            queryType = "0";
                            break;
                    }
                }
                else
                {
                    queryType = "0";
                }

                string queryFormat = string.Empty;
                if (cbMtlCategoryStatus.SelectedItem != null)
                {
                    switch (cbMtlCategoryStatus.SelectedItem.ToString())
                    {
                        case "有库存":
                            queryFormat = "INSTOCK";
                            break;
                        case "须备料":
                            queryFormat = "PRESTOCK";
                            break;
                        case "须配料":
                            queryFormat = "MIXSTOCK";
                            break;
                        default:
                            queryFormat = "";
                            break;
                    }
                }

                string queryTip = string.Empty;
                if (cbTipCn.SelectedItem != null)
                {
                    switch (cbTipCn.SelectedItem.ToString())
                    {
                        case "附件":
                            queryTip = "FUJIAN";
                            break;
                        case "散件":
                            queryTip = "SANJIAN";
                            break;
                        case "两器":
                            queryTip = "LIANGQI";
                            break;
                        case "铜管":
                            queryTip = "TONGGUAN";
                            break;
                        case "铝箔":
                            queryTip = "LVBO";
                            break;
                        case "配管":
                            queryTip = "PEIGUAN";
                            break;
                        case "其他":
                            queryTip = "QITA";
                            break;
                        default:
                            queryTip = "";
                            break;
                    }
                }
                string queryTime = (cbTaskTime.SelectedItem == null) ? null : cbTaskTime.Text;
                string queryMaterial = (cbMaterial.SelectedItem == null) ? null : cbMaterial.Text;
                string queryMark = (cbRelated.SelectedItem == null) ? null : cbRelated.Text;

                AscmGetMaterialTask taskModel = new AscmGetMaterialTask();
                taskModel.warehouserId = cbWarehouse.Text.Trim().ToUpper();
                taskModel.tip = queryTip;
                taskModel.productLine = tbProductLine.Text;
                taskModel.mtlCategoryStatus = queryFormat;
                taskModel.taskTime = queryTime;
                taskModel.IdentificationId = int.Parse(queryType);
                taskModel.materialDocNumber = queryMaterial;
                taskModel.relatedMark = queryMark;

                ascmGetMaterialTask = taskModel;

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 11
0
 public void Update(AscmGetMaterialTask ascmGetMaterialTask)
 {
     try
     {
         using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction())
         {
             try
             {
                 YnDaoHelper.GetInstance().nHibernateHelper.Update<AscmGetMaterialTask>(ascmGetMaterialTask);
                 tx.Commit();//正确执行提交
             }
             catch (Exception ex)
             {
                 tx.Rollback();//回滚
                 YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Update AscmGetMaterialTask)", ex);
                 throw ex;
             }
         }
     }
     catch (Exception ex)
     {
         YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Save AscmGetMaterialTask)", ex);
         throw ex;
     }
 }
        public void saveTasks(List<AscmGetMaterialCreateTask> listTasks)
        {
            string userName = string.Empty;
            if (User.Identity.IsAuthenticated)
            {
                userName = User.Identity.Name;
            }
            string bom_ids = string.Empty;
            int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmGetMaterialTask");

            List<AscmGetMaterialTask> myTasks = new List<AscmGetMaterialTask>();
            List<AscmDiscreteJobs> myJobs = new List<AscmDiscreteJobs>();
            List<AscmWipRequirementOperations> myBoms = new List<AscmWipRequirementOperations>();

            foreach (AscmGetMaterialCreateTask task in listTasks)
            {
                //任务表
                AscmGetMaterialTask myTask = new AscmGetMaterialTask();
                myTask.id = maxId + 1 + myTasks.Count;
                myTask.taskId = task.taskId;
                myTask.productLine = task.productLine;
                myTask.warehouserId = task.warehouserId;
                myTask.mtlCategoryStatus = task.categoryStatus;
                myTask.rankerId = task.rankMan;
                myTask.workerId = string.Empty;
                myTask.starTime = string.Empty;
                myTask.endTime = string.Empty;
                myTask.status = "NOTALLOCATE";
                myTask.tip = string.Empty;

                myTask.createUser = userName;
                myTask.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                myTask.modifyUser = userName;
                myTask.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");

                myTask.IdentificationId = task.IdentificationId;
                myTask.materialType = task.materialType;
                myTask.materialDocNumber = task.materialDocNumber;
                myTask.uploadDate = task.uploadDate;
                myTask.taskTime = task.taskTime;
                myTask.warehouserPlace = task.warehouserPlace;
                myTask.which = task.which;

                myTasks.Add(myTask);

                foreach (AscmDiscreteJobs job in task.ascmDiscreteJobsList)
                {
                    foreach (AscmWipRequirementOperations bom in job.listAscmWipBom)
                    {
                        //BOM清单
                        bom.taskId = myTask.id;
                        myBoms.Add(bom);
                    }
                }
            }

            string ids = string.Empty;
            foreach (AscmGetMaterialCreateTask task in listTasks)
            {
                foreach (AscmDiscreteJobs job in task.ascmDiscreteJobsList)
                {
                    if (!string.IsNullOrEmpty(ids))
                        ids += ",";
                    ids += "'" + job.jobId + "'";
                }
            }
            string sql = "from AscmDiscreteJobs where JOBID in (" + ids + ")";
            IList<AscmDiscreteJobs> ilistAscmDiscreteJobs = YnDaoHelper.GetInstance().nHibernateHelper.Find<AscmDiscreteJobs>(sql);
            if (ilistAscmDiscreteJobs != null && ilistAscmDiscreteJobs.Count > 0)
            {
                myJobs = YnBaseClass2.Helper.ConvertHelper.ConvertIListToList<AscmDiscreteJobs>(ilistAscmDiscreteJobs);
                foreach (AscmDiscreteJobs ascmDiscreteJobs in myJobs)
                {
                    ascmDiscreteJobs.status = 2;
                }
            }
            foreach (AscmWipRequirementOperations bom in myBoms)
            {
                if (!string.IsNullOrEmpty(bom_ids))
                    bom_ids += ",";
                bom_ids += "" + bom.id + "";
            }
            //添加任务
            AscmGetMaterialTaskService.GetInstance().Save(myTasks);
            //更新作业表
            //AscmDiscreteJobsService.GetInstance().Update(myJobs);
            //更新BOM表
            //AscmWipRequirementOperationsService.GetInstance().Update(myBoms);
        }
        public ContentResult AddTaskSave(AscmGetMaterialTask taskModel, string warehouserPlace)
        {
            JsonObjectResult jsonObjectResult = new JsonObjectResult();
            try
            {
                string userName = string.Empty;
                string userRole = string.Empty;
                if (User.Identity.IsAuthenticated)
                {
                    userName = User.Identity.Name;
                }
                List<YnRole> listYnRole = YnRoleService.GetInstance().GetListInUser(userName);
                int nI = 0;
                foreach (YnRole role in listYnRole)
                {
                    if (role.name == "领料员")
                    {
                        nI++;
                    }
                }
                if (nI != 0)
                {
                    userRole = userName;
                }

                if (string.IsNullOrEmpty(taskModel.tip))
                    throw new Exception("作业内容不能为空!");
                string date = DateTime.Now.ToString("yyyy-MM-dd");
                string datetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmGetMaterialTask where TaskId like '%L%' AND CREATETIME like '%" + date + "%'");
                taskModel.taskId = (maxId == 0) ? "L1001" : "L"+(int.Parse(AscmGetMaterialTaskService.GetInstance().Get(maxId).taskId.Substring(1, 4)) + 1).ToString();
                taskModel.id = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmGetMaterialTask ")+1;
                taskModel.createUser = userName;
                taskModel.modifyUser = userName;
                taskModel.createTime = datetime;
                taskModel.modifyTime = datetime;
                if (!string.IsNullOrEmpty(userRole))
                {
                    taskModel.workerId = userRole;
                    taskModel.status = AscmGetMaterialTask.StatusDefine.notExecute;
                }
                else
                {
                    taskModel.status = AscmGetMaterialTask.StatusDefine.notAllocate;
                }
                taskModel.materialType = 1;
                taskModel.uploadDate = date;

                if (!string.IsNullOrEmpty(taskModel.relatedMarkId.ToString()) && taskModel.relatedMarkId > 0)
                {
                    AscmMarkTaskLog ascmMarkTaskLog = AscmMarkTaskLogService.GetInstance().Get(taskModel.relatedMarkId);
                    if (ascmMarkTaskLog != null)
                    {
                        ascmMarkTaskLog.isMark = 0;
                        ascmMarkTaskLog.modifyUser = userName;
                        ascmMarkTaskLog.modifyTime = datetime;

                        AscmMarkTaskLogService.GetInstance().Update(ascmMarkTaskLog);
                    }
                    taskModel.relatedMark += taskModel.relatedMarkId.ToString();
                }

                AscmGetMaterialTaskService.GetInstance().Save(taskModel);
                jsonObjectResult.result = true;
            }
            catch (Exception ex)
            {
                jsonObjectResult.message = ex.Message;
            }
            string sReturn = JsonConvert.SerializeObject(jsonObjectResult);
            return Content(sReturn);
        }
        public ContentResult EditTaskSave(AscmGetMaterialTask ascmGetMaterialTask_Model, int? id)
        {
            JsonObjectResult jsonObjectResult = new JsonObjectResult();
            try
            {
                string userName = string.Empty;
                if (User.Identity.IsAuthenticated)
                {
                    userName = User.Identity.Name;
                }

                if (id.HasValue)
                {
                    AscmGetMaterialTask ascmGetMaterialTask = AscmGetMaterialTaskService.GetInstance().Get(ascmGetMaterialTask_Model.id);
                    List<AscmAllocateRule> list = new List<AscmAllocateRule>();
                    if (ascmGetMaterialTask.taskId.Substring(0, 1) == AscmCommonHelperService.GetInstance().GetConfigTaskWords(0))
                    {
                        List<AscmAllocateRule> listMinus = AscmAllocateRuleService.GetInstance().GetList("from AscmAllocateRule where workerName = '" + ascmGetMaterialTask.workerId + "'", false, false, false);
                        if (listMinus != null && listMinus.Count > 0)
                        {
                            foreach (AscmAllocateRule ascmAllocateRule in listMinus)
                            {
                                ascmAllocateRule.taskCount--;
                                ascmAllocateRule.modifyUser = userName;
                                ascmAllocateRule.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                                list.Add(ascmAllocateRule);
                            }
                        }
                        List<AscmAllocateRule> listPlus = AscmAllocateRuleService.GetInstance().GetList("from AscmAllocateRule where workerName = '" + ascmGetMaterialTask_Model.WorkerName + "'", false, false, false);
                        if (listPlus != null && listPlus.Count > 0)
                        {
                            foreach (AscmAllocateRule ascmAllocateRule in listPlus)
                            {
                                ascmAllocateRule.taskCount++;
                                ascmAllocateRule.modifyUser = userName;
                                ascmAllocateRule.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                                list.Add(ascmAllocateRule);
                            }
                        }
                        AscmAllocateRuleService.GetInstance().Update(list);
                    }
                    if (!string.IsNullOrEmpty(ascmGetMaterialTask_Model.WorkerName))
                    {
                        ascmGetMaterialTask.workerId = ascmGetMaterialTask_Model.WorkerName;
                        ascmGetMaterialTask.status = "NOTEXECUTE";
                        AscmGetMaterialTaskService.GetInstance().Update(ascmGetMaterialTask);
                    }
                }
                jsonObjectResult.result = true;
            }
            catch (Exception ex)
            {
                jsonObjectResult.message = ex.Message;
            }
            string sReturn = JsonConvert.SerializeObject(jsonObjectResult);
            return Content(sReturn);
        }
Esempio n. 15
0
        /// <summary>
        /// 备料信息
        /// </summary>
        /// <param name="list">数据List</param>
        public void UpdateWmsPreparationInfo(List<WmsAndLogistics> list)
        {
            List<AscmWipRequirementOperations> listRequirementOperations = new List<AscmWipRequirementOperations>();
            try
            {
                if (list != null && list.Count > 0)
                {
                    foreach (WmsAndLogistics wmsAndLogistics in list)
                    {
                        string sql = "from AscmWipRequirementOperations";
                        string where = "", whereQueryWord = "";
                        if (!string.IsNullOrEmpty(wmsAndLogistics.wipEntityId.ToString()) && !string.IsNullOrEmpty(wmsAndLogistics.materialId.ToString()))
                        {
                            whereQueryWord = "wipEntityId =" + wmsAndLogistics.wipEntityId.ToString();
                            where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                            whereQueryWord = "inventoryItemId = " + wmsAndLogistics.materialId.ToString();
                            where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                            if (!string.IsNullOrEmpty(where))
                                sql += " where " + where;
                            IList<AscmWipRequirementOperations> ilistRequirementOperations = YnDaoHelper.GetInstance().nHibernateHelper.Find<AscmWipRequirementOperations>(sql);
                            if (ilistRequirementOperations.Count > 0 && ilistRequirementOperations != null)
                            {
                                List<AscmWipRequirementOperations> templist = YnBaseClass2.Helper.ConvertHelper.ConvertIListToList<AscmWipRequirementOperations>(ilistRequirementOperations);
                                //foreach (AscmWipRequirementOperations ascmWipRequirementOperations in templist)
                                //{
                                //    ascmWipRequirementOperations.wmsPreparationQuantity += wmsAndLogistics.quantity;
                                //    if (!string.IsNullOrEmpty(ascmWipRequirementOperations.wmsPreparationString))
                                //        ascmWipRequirementOperations.wmsPreparationString += ",";
                                //    ascmWipRequirementOperations.wmsPreparationString += wmsAndLogistics.preparationString + "[" + wmsAndLogistics.quantity + "]";
                                //    listRequirementOperations.Add(ascmWipRequirementOperations);
                                //}

                                foreach (AscmWipRequirementOperations ascmWipRequirementOperations in templist)
                                {
                                    if (ascmWipRequirementOperations.supplySubinventory == wmsAndLogistics.warehouseId)
                                    {
                                        //作业BOM子库与备料子库相同
                                        ascmWipRequirementOperations.wmsPreparationQuantity += wmsAndLogistics.quantity;
                                        if (!string.IsNullOrEmpty(ascmWipRequirementOperations.wmsPreparationString))
                                            ascmWipRequirementOperations.wmsPreparationString += ",";
                                        ascmWipRequirementOperations.wmsPreparationString += wmsAndLogistics.preparationString + "[" + wmsAndLogistics.quantity + "]";
                                        listRequirementOperations.Add(ascmWipRequirementOperations);
                                    }
                                    else
                                    {
                                        //作业BOM子库与备料子库不同.具体步骤如下:①判断是否包含该任务,包括则关联BOM,否则创建任务;②与作业BOM子库与备料子库相同操作
                                        string createTime = "";
                                        int taskId = AscmGetMaterialTaskService.GetInstance().IsContainsMeetTheConditionTask(wmsAndLogistics.warehouseId, ascmWipRequirementOperations.inventoryItemId, ascmWipRequirementOperations.wipEntityId, ref createTime);

                                        if (taskId > 0)
                                        {
                                            ascmWipRequirementOperations.taskId = taskId;//修改任务与Bom关联信息
                                            ascmWipRequirementOperations.wmsPreparationWarehouse = wmsAndLogistics.warehouseId;

                                            ascmWipRequirementOperations.wmsPreparationQuantity += wmsAndLogistics.quantity;
                                            if (!string.IsNullOrEmpty(ascmWipRequirementOperations.wmsPreparationString))
                                                ascmWipRequirementOperations.wmsPreparationString += ",";
                                            ascmWipRequirementOperations.wmsPreparationString += wmsAndLogistics.preparationString + "[" + wmsAndLogistics.quantity + "]";
                                            listRequirementOperations.Add(ascmWipRequirementOperations);
                                        }
                                        else
                                        {
                                            AscmMaterialItem ascmMaterialItem = AscmMaterialItemService.GetInstance().Get(ascmWipRequirementOperations.inventoryItemId);
                                            if (ascmMaterialItem == null)
                                                throw new Exception("Bom关联物料实体查询失败!");

                                            AscmWipEntities ascmWipEntities = AscmWipEntitiesService.GetInstance().Get(ascmWipRequirementOperations.wipEntityId);
                                            if (ascmWipEntities == null)
                                                throw new Exception("Bom关联作业实体查询失败!");

                                            List<AscmDiscreteJobs> listAscmDiscreteJobs = AscmDiscreteJobsService.GetInstance().GetList("from AscmDiscreteJobs where jobId = '" + ascmWipEntities.name + "'", true);
                                            if (listAscmDiscreteJobs == null || listAscmDiscreteJobs.Count == 0)
                                                throw new Exception("Bom关联作业实体查询失败!");

                                            string productLine = listAscmDiscreteJobs[0].productLine;
                                            int identificationId = listAscmDiscreteJobs[0].identificationId;
                                            string rankerId = listAscmDiscreteJobs[0].workerId;
                                            string uploadDate = listAscmDiscreteJobs[0].time;
                                            string taskTime = listAscmDiscreteJobs[0].onlineTime;

                                            AscmGetMaterialTask ascmGetMaterialTask = new AscmGetMaterialTask();
                                            int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmGetMaterialTask where taskId like '%T%' and createTime like '%" + createTime + "%'");
                                            ascmGetMaterialTask.id = maxId++;
                                            ascmGetMaterialTask.taskId = (maxId == 0) ? "T0001" : "T" + (int.Parse(AscmGetMaterialTaskService.GetInstance().Get(maxId).taskId.Substring(1, 4)) + 1).ToString();
                                            ascmGetMaterialTask.warehouserId = wmsAndLogistics.warehouseId;
                                            object obj = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select description from AscmWarehouse where id = '" + wmsAndLogistics.warehouseId + "'");
                                            if (obj != null)
                                                ascmGetMaterialTask.warehouserPlace = obj.ToString();
                                            ascmGetMaterialTask.createUser = "******";
                                            ascmGetMaterialTask.createTime = createTime + " " + DateTime.Now.TimeOfDay.ToString("HH:mm");
                                            ascmGetMaterialTask.modifyUser = "******";
                                            ascmGetMaterialTask.modifyTime = createTime + " " + DateTime.Now.TimeOfDay.ToString("HH:mm");
                                            ascmGetMaterialTask.IdentificationId = identificationId;
                                            ascmGetMaterialTask.productLine = productLine;

                                            if (ascmGetMaterialTask.IdentificationId == 1)
                                                ascmGetMaterialTask.mtlCategoryStatus = ascmMaterialItem.zMtlCategoryStatus;
                                            else if (ascmGetMaterialTask.IdentificationId == 2)
                                                ascmGetMaterialTask.mtlCategoryStatus = ascmMaterialItem.dMtlCategoryStatus;

                                            ascmGetMaterialTask.rankerId = rankerId;
                                            ascmGetMaterialTask.status = AscmGetMaterialTask.StatusDefine.notAllocate;

                                            if (ascmGetMaterialTask.mtlCategoryStatus == MtlCategoryStatusDefine.preStock)
                                                ascmGetMaterialTask.materialDocNumber = ascmMaterialItem.docNumber;

                                            ascmGetMaterialTask.materialType = AscmGetMaterialTask.materialTypeDefine.ts;
                                            ascmGetMaterialTask.uploadDate = uploadDate.Substring(0,10);
                                            ascmGetMaterialTask.taskTime = taskTime;

                                            object which = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(which) from AscmGetMaterialTask where taskId like '%T%' and createTime like '%" + createTime + "%'");
                                            if (which == null)
                                                throw new Exception("领料任务第几次生产查询失败!");
                                            ascmGetMaterialTask.which = int.Parse(which.ToString());

                                            AscmGetMaterialTaskService.GetInstance().Save(ascmGetMaterialTask);//新建新任务

                                            ascmWipRequirementOperations.taskId = ascmGetMaterialTask.id;//添加新任务与Bom关联关系
                                            ascmWipRequirementOperations.wmsPreparationWarehouse = wmsAndLogistics.warehouseId;

                                            ascmWipRequirementOperations.wmsPreparationQuantity += wmsAndLogistics.quantity;
                                            if (!string.IsNullOrEmpty(ascmWipRequirementOperations.wmsPreparationString))
                                                ascmWipRequirementOperations.wmsPreparationString += ",";
                                            ascmWipRequirementOperations.wmsPreparationString += wmsAndLogistics.preparationString + "[" + wmsAndLogistics.quantity + "]";
                                            listRequirementOperations.Add(ascmWipRequirementOperations);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (listRequirementOperations != null && listRequirementOperations.Count > 0)
                    {
                        AscmWipRequirementOperationsService.GetInstance().Update(listRequirementOperations);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }