public static string GetPlanNumber() { var lastday = DateTime.Today; var joinProduce = new JoinAlias(typeof(ProduceOutput)); var joinDetail = new JoinAlias(typeof(ProduceOutput_Detail)); var joinChengPin = new JoinAlias(typeof(ChengPinToBanChengPinConfig)); var joinNumber = new JoinAlias(typeof(ButcheryGoods)); var query = new DQueryDom(joinDetail); query.From.AddJoin(JoinType.Left, new DQDmoSource(joinProduce), DQCondition.EQ(joinProduce, "ID", joinDetail, "ProduceOutput_ID")); query.From.AddJoin(JoinType.Left, new DQDmoSource(joinChengPin), DQCondition.EQ(joinDetail, "Goods_ID", joinChengPin, "Goods2_ID")); query.From.AddJoin(JoinType.Left, new DQDmoSource(joinNumber), DQCondition.EQ(joinChengPin, "Goods2_ID", joinNumber, "ID")); //主单位 query.Columns.Add(DQSelectColumn.Field("MainUnitRatio", joinNumber)); //辅单位 query.Columns.Add(DQSelectColumn.Field("SecondUnitRatio", joinNumber)); //成品数量 要做的操作是 成品数量/(主单位*辅单位) query.Columns.Add(DQSelectColumn.Field("Number", joinDetail)); query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual(joinProduce, "Time", lastday.AddDays(-1))); query.Where.Conditions.Add(DQCondition.LessThan(joinProduce, "Time", lastday)); var list = new List <GetChengPin>(); using (var session = Dmo.NewSession()) { using (var reader = session.ExecuteReader(query)) { while (reader.Read()) { var dto = new GetChengPin(); dto.MainUnitRatio = (decimal)reader[4]; dto.SecondUnitRatio = (decimal)reader[5]; dto.Number = (Money <decimal>)reader[6]; dto.PlanNumber = Convert.ToInt32(dto.Number / (dto.MainUnitRatio * dto.SecondUnitRatio)); list.Add(dto); } } } return(JsonConvert.SerializeObject(list)); }
public static string GetFinishProductList() { var lastday = DateTime.Today; var joinProduce = new JoinAlias(typeof(ProduceOutput)); var joinDetail = new JoinAlias(typeof(ProduceOutput_Detail)); var joinChengPin = new JoinAlias(typeof(ChengPinToBanChengPinConfig)); var query = new DQueryDom(joinDetail); query.From.AddJoin(JoinType.Left, new DQDmoSource(joinProduce), DQCondition.EQ(joinProduce, "ID", joinDetail, "ProduceOutput_ID")); query.From.AddJoin(JoinType.Left, new DQDmoSource(joinChengPin), DQCondition.EQ(joinDetail, "Goods_ID", joinChengPin, "Goods2_ID")); query.Columns.Add(DQSelectColumn.Field("Goods_ID", joinDetail)); query.Columns.Add(DQSelectColumn.Field("Goods_Name", joinDetail)); query.Columns.Add(DQSelectColumn.Field("Goods_ID", joinChengPin)); query.Columns.Add(DQSelectColumn.Field("Goods_Name", joinChengPin)); query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual(joinProduce, "Time", lastday.AddDays(-1))); query.Where.Conditions.Add(DQCondition.LessThan(joinProduce, "Time", lastday)); var list = new List <GetChengPin>(); using (var session = Dmo.NewSession()) { using (var reader = session.ExecuteReader(query)) { while (reader.Read()) { var dto = new GetChengPin(); dto.Goods_ID = Convert.ToInt64(reader[0]); dto.Goods_Name = reader[1].ToString(); dto.Goods2_ID = Convert.ToInt64(reader[2]); dto.Goods2_Name = reader[3].ToString(); list.Add(dto); } } } return(JsonConvert.SerializeObject(list)); }