public async Task <ICMODispBillDetaileds> ICMOInspectBillDetailed(ICMODispBillDetailedInput input)
        {
            ICMODispBillDetaileds icmoDispBillDetaileds = new ICMODispBillDetaileds();

            //
            icmoDispBillDetaileds.IcmoInspectBill =
                await JIT_ICMOInspectBill.GetAll().FirstOrDefaultAsync(f =>
                                                                       f.FID == input.FID && f.FOperID == input.FOperID) ??
                new ICMOInspectBill();

            //
            //var tmp = JIT_TB_BadItemRelation.GetAll()
            //    .Join(JIT_ICQualityRpt.GetAll(),c=>c.FID, p => p.FItemID, (c, p) => new {p.FID,p.FAuxQty,p.FItemID,p.FNote,p.FRemark,p.ICMOInspectBillID,c.FName,c.FDeleted})
            //    .Where(w => (w.ICMOInspectBillID == input.FID || w.FDeleted == true)).Distinct().ToList();
            //icmoDispBillDetaileds.IcQualityRptsList =  new List<ICQualityRptDto>();
            //foreach (var item in tmp)
            //{
            //    var t = new ICQualityRptDto(){ FID = item.FID,FAuxQty = item.FAuxQty,FItemID = item.FItemID,FName = item.FName,FNote = item.FNote,FRemark = item.FRemark,ICMOInspectBillID = input.FID };
            //    icmoDispBillDetaileds.IcQualityRptsList.Add(t);
            //}
            //

            icmoDispBillDetaileds.IcQualityRptsList =
                JIT_ICQualityRpt.GetAll().Where(w => w.ICMOInspectBillID == input.FID).ToList();
            return(icmoDispBillDetaileds);
        }
        /// <summary>
        /// 质检汇报明细保存
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <bool> ICMODispBillSave(ICMODispBillDetaileds input)
        {
            try
            {
                // 查询回之前的
                var query = await JIT_ICMOInspectBill.GetAll().Where(w => w.FID == input.IcmoInspectBill.FID)
                            .FirstOrDefaultAsync() ?? new ICMOInspectBill();

                query.FID     = input.IcmoInspectBill.FID;
                query.FWorker = AbpSession.UserId.ToString();
                query.FNote   = input.IcmoInspectBill.FNote;
                query.FOperID = input.IcmoInspectBill.FOperID;
                //query.FBillNo = input.IcmoInspectBill.FBillNo;
                query.FStatus      = input.IcmoInspectBill.FAuxQty == input.IcmoInspectBill.FCheckAuxQty ? 1 : 0;
                query.FTranType    = 0;
                query.FAuxQty      = input.IcmoInspectBill.FAuxQty;
                query.FCheckAuxQty = input.IcmoInspectBill.FCheckAuxQty;
                query.FPassAuxQty  = input.IcmoInspectBill.FPassAuxQty;
                query.FFailAuxQty  = input.IcmoInspectBill.FFailAuxQty;
                query.FFailAuxQtyP = input.IcmoInspectBill.FFailAuxQtyP;
                query.FFailAuxQtyM = input.IcmoInspectBill.FFailAuxQtyM;
                query.FPassAuxQtyP = input.IcmoInspectBill.FPassAuxQtyP;
                query.FPassAuxQtyM = input.IcmoInspectBill.FPassAuxQtyM;
                query.FInspector   = AbpSession.UserId.ToString();
                query.FYSQty       = query.FPassAuxQty < input.IcmoInspectBill.FYSQty
                    ? Convert.ToDecimal(query.FPassAuxQty)
                    : Convert.ToDecimal(query.FPassAuxQty % input.IcmoInspectBill.FYSQty);
                query.FInspectTime = DateTime.Now;

                // 更新质检单
                await JIT_ICMOInspectBill.UpdateAsync(query);

                // 删除之前所有不良项目
                var entity = JIT_ICQualityRpt.GetAll().Where(w => w.FID == query.FID);
                foreach (var item in entity)
                {
                    await JIT_ICQualityRpt.DeleteAsync(item);
                }

                // 重新添加所有不良项目
                foreach (var item in input.IcQualityRptsList.Where(w => w.FAuxQty > 0))
                {
                    item.ICMOInspectBillID = query.FID; // 关联主表
                    item.FID = Guid.NewGuid().ToString();
                    await JIT_ICQualityRpt.InsertAsync(item);
                }

                // 所有汇报
                var ICMODispBillList =
                    await JIT_ICMOInspectBill.GetAll().Where(w => w.ICMODispBillID == query.ICMODispBillID).ToListAsync();

                decimal FCheckAuxQty =
                    Convert.ToDecimal(ICMODispBillList.Sum(s => s.FCheckAuxQty));
                decimal FAuxQty =
                    Convert.ToDecimal(ICMODispBillList.Sum(s => s.FAuxQty));
                decimal FFailAuxQty =
                    Convert.ToDecimal(ICMODispBillList.Sum(s => s.FFailAuxQty));
                decimal FPassAuxQty =
                    Convert.ToDecimal(ICMODispBillList.Sum(s => s.FPassAuxQty));


                // 更新主表
                var query1 = await JIT_ICMODispBill.GetAll().Where(w => w.FID == query.ICMODispBillID)
                             .FirstOrDefaultAsync();

                query1.FFInspectAuxQty = FCheckAuxQty;
                query1.FFinishAuxQty   = FAuxQty;
                query1.FFailAuxQty     = FFailAuxQty;
                query1.FPassAuxQty     = FPassAuxQty;

                await JIT_ICMODispBill.UpdateAsync(query1);

                // 没有异常返回 true
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);

                // 异常返回 false
                return(false);
            }
        }