public Result PostSmartProcessCodeCategory([FromBody] IEnumerable <SmartProcessCodeCategoryDetail> processCodeCategories)
        {
            if (processCodeCategories == null || !processCodeCategories.Any())
            {
                return(Result.GenError <Result>(Error.ParamError));
            }
            if (processCodeCategories.Any(x => x.Category.IsNullOrEmpty()))
            {
                return(Result.GenError <Result>(Error.SmartProcessCodeCategoryNotEmpty));
            }

            var wId   = processCodeCategories.FirstOrDefault()?.WorkshopId ?? 0;
            var sames = processCodeCategories.Select(x => x.Category);

            if (SmartProcessCodeCategoryHelper.GetHaveSame(wId, sames))
            {
                return(Result.GenError <Result>(Error.SmartProcessCodeCategoryDuplicate));
            }

            var userId         = Request.GetIdentityInformation();
            var markedDateTime = DateTime.Now;

            foreach (var processCodeCategory in processCodeCategories)
            {
                processCodeCategory.CreateUserId   = userId;
                processCodeCategory.MarkedDateTime = markedDateTime;
                processCodeCategory.Remark         = processCodeCategory.Remark ?? "";
            }
            SmartProcessCodeCategoryHelper.Instance.Add(processCodeCategories);

            var newCategories = processCodeCategories.Select(x => x.Category);
            var categories    = SmartProcessCodeCategoryHelper.GetDetail(newCategories);

            var processes = processCodeCategories.SelectMany(x => x.Processes);

            if (processes.Any())
            {
                foreach (var processCodeCategory in processCodeCategories)
                {
                    if (processCodeCategory.Processes != null && processCodeCategory.Processes.Any())
                    {
                        var categoryId = categories.FirstOrDefault(x => x.Category == processCodeCategory.Category)?.Id ?? 0;
                        foreach (var process in processCodeCategory.Processes)
                        {
                            process.CreateUserId          = userId;
                            process.MarkedDateTime        = markedDateTime;
                            process.ProcessCodeCategoryId = categoryId;
                        }
                    }
                }
                SmartProcessCodeCategoryProcessHelper.Instance.Add(processes);
            }

            return(Result.GenError <Result>(Error.Success));
        }
        public DataResult GetSmartProcessCodeCategory([FromQuery] int qId, int wId, bool menu)
        {
            var result = new DataResult();

            result.datas.AddRange(menu
                ? SmartProcessCodeCategoryHelper.GetMenu(qId, wId)
                : SmartProcessCodeCategoryHelper.GetDetail(qId, wId));
            if (qId != 0 && !result.datas.Any())
            {
                result.errno = Error.SmartProcessCodeCategoryNotExist;
                return(result);
            }
            return(result);
        }