public ActionResult setStatus(string userId, string city, string month, string prodect, int status, string BrandCode) { PSIApp psiApp = new PSIApp(); psiApp.setStatus(prodect, month, city, userId, status, BrandCode); return(Content("操作成功!")); }
public ActionResult cmQty(sQtyModel model) { PSIApp psiApp = new PSIApp(); marketSalesApp salesApp = new marketSalesApp(); psiApp.cQty(model.prodect, model.userid, model.userid, salesApp.getOrginfoBySubId(model.orgId, "BU").id, model.orgId, model.qty, model.day, model.BrandCode); return(Content("提交成功!")); }
public ActionResult shTag(shTagModel model) { if (model.type == 1) { JS5_S12_SALES_TARGET_BILL_DTableAdapter dad = new JS5_S12_SALES_TARGET_BILL_DTableAdapter(); int totalQty = (int)dad.QtyQuery(model.BrandCode, model.PorgId, model.prodect, model.bllNo); //var tagEnt = tagAd.GetDataByNo(model.bllNo); if (totalQty <= 0) { return(Content("分配失败,未找到目标!")); } marketSalesApp salesApp = new marketSalesApp(); //查询城市列表 //JS5_S12_SALES_MANAGE_ORG_INFOTableAdapter orgInfo = new JS5_S12_SALES_MANAGE_ORG_INFOTableAdapter(); // List<DataSynchronizationLib.SCM.JS5_S12_SALES_MANAGE_ORG_INFORow> citys = new List<DataSynchronizationLib.SCM.JS5_S12_SALES_MANAGE_ORG_INFORow>(); // var orgs = orgInfo.GetDataByPid(model.PorgId); //foreach (var org in orgs) //{ // foreach (var orgCity in orgInfo.GetDataByPid(org.ID)) //{ // citys.Add(orgCity); //} //} var orgs = salesApp.getOrginfoByPCode(model.PorgId, "CITY"); PSIApp psiApp = new PSIApp(); foreach (var org in orgs) { int qty = (totalQty / orgs.Count) + 1; var sales = salesApp.getUserInfoByOrgId(org.id); if (sales != null) { psiApp.shTag(model.prodect, sales.id, model.userid, model.PorgId, org.id, model.month, qty, model.BrandCode); } } } else { PSIApp psiApp = new PSIApp(); psiApp.shTag(model.prodect, model.userid, model.userid, model.PorgId, model.orgId, model.month, model.qty, model.BrandCode); } return(Content("分配成功!")); }
public PartialViewResult DayDataView(string userId, string city, string month, string prodect, string BrandCode) { //prodect = "4"; PSIApp psiApp = new PSIApp(); var ents = psiApp.CmList(prodect, month, city, userId, BrandCode); tagModel model = new tagModel(); model.subModel = new List <qtyModel>(); foreach (var ent in ents.OrderBy(p => p.day)) { model.subModel.Add(new qtyModel() { day = ent.day.Value.ToString("yyyy-MM-dd"), value = ent.cmQty.Value }); } return(PartialView("_PSIDayPartialPage", model)); }
private VModel getdata(string BrandValue, string ProdectValue, string MonthValue, string UserId, int type, string salesCode, string orgCode) { VModel model = new VModel(); marketSalesApp salesApp = new marketSalesApp(); //组织ID 219 //查询目标总数 model.type = type; DateTime m = DateTime.ParseExact(MonthValue, "yyyyMM", CultureInfo.CurrentCulture); if (type == 2) { string porgCode = salesApp.getOrginfoBySubId(orgCode, "BU").id; model.OrgId = orgCode; model.OrgName = salesApp.getOrgInfo(orgCode).MANAGE_ORG_NAME; model.Prodect = ProdectValue; //查找Bill单号 JS5_S12_SALES_TARGET_BILL_MTableAdapter ad = new JS5_S12_SALES_TARGET_BILL_MTableAdapter(); var totalEnts = ad.GetDataBy(salesApp.getOrginfoBySubId(porgCode, "CHANNEL").id, model.Prodect, m.ToString("yyyy/MM"), BrandValue); if (totalEnts.Count <= 0) { model.TotalTagQty = 0; model.billNo = null; } else { model.billNo = totalEnts.First().BILL_NO; JS5_S12_SALES_TARGET_BILL_DTableAdapter dad = new JS5_S12_SALES_TARGET_BILL_DTableAdapter(); model.TotalTagQty = (int)dad.QtyQuery(BrandValue, porgCode, model.Prodect, model.billNo); } model.Brand = BrandValue; JS5_S12_BRAND_INFOTableAdapter BandAd = new JS5_S12_BRAND_INFOTableAdapter(); model.BrandName = BandAd.GetDataByCode(BrandValue).First().BRAND_NAME; model.Month = MonthValue; model.MonthName = m.ToString("yyyy年MM月"); JS5_S12_PRODUCT_TYPE_INFOTableAdapter prdAd = new JS5_S12_PRODUCT_TYPE_INFOTableAdapter(); model.ProdectName = prdAd.GetDataByCode(ProdectValue).First().TREE_NODE_NAME; //查询总共已提交数量 PSIApp psiApp = new PSIApp(); var cents = psiApp.CmList(model.Prodect, MonthValue, porgCode, BrandValue); model.TotalCQty = cents.Sum(p => p.cmQty).Value;//psiApp.TotalCmQty(ProdectValue, MonthValue, model.OrgId); model.UserId = UserId; model.subModel = new List <subVModel>(); var ents = psiApp.CmList(model.Prodect, MonthValue, model.OrgId, UserId, BrandValue); model.SelfTotalTagQty = psiApp.TagList(model.Prodect, MonthValue, model.OrgId, UserId, BrandValue).Sum(p => p.totalTagQty).Value; model.SelfTotalCQty = ents.Sum(p => p.cmQty).Value;//psiApp.TotalCmQty(ProdectValue, MonthValue, model.OrgId,UserId); model.cQtyModel = new List <qtyModel>(); DateTime startDay = m; DateTime temp = m; for (int i = 0; i < 35; i++) { if (startDay.Month == temp.Month) { int isClose = 0; if (DateTime.Compare(temp, DateTime.ParseExact(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"), "yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture)) < 0) { isClose = 1; } var ent = ents.Find(p => p.day.Value.ToString("yyyy-MM-dd").Equals(temp.ToString("yyyy-MM-dd"))); if (ent != null) { model.cQtyModel.Add(new qtyModel() { day = temp.ToString("yyyy-MM-dd"), status = ent.status.HasValue ? ent.status.Value : 0, value = ent.cmQty.Value, isClose = isClose }); } else { model.cQtyModel.Add(new qtyModel() { day = temp.ToString("yyyy-MM-dd"), status = 0, value = 0, isClose = isClose }); } } temp = temp.AddDays(1); } } else { model.OrgId = orgCode; model.OrgName = salesApp.getOrgInfo(orgCode).MANAGE_ORG_NAME; model.Prodect = ProdectValue; //查找Bill单号 JS5_S12_SALES_TARGET_BILL_MTableAdapter ad = new JS5_S12_SALES_TARGET_BILL_MTableAdapter(); var totalEnts = ad.GetDataBy(salesApp.getOrginfoBySubId(orgCode, "CHANNEL").id, model.Prodect, m.ToString("yyyy/MM"), BrandValue); if (totalEnts.Count <= 0) { model.TotalTagQty = 0; model.billNo = null; } else { model.billNo = totalEnts.First().BILL_NO; JS5_S12_SALES_TARGET_BILL_DTableAdapter dad = new JS5_S12_SALES_TARGET_BILL_DTableAdapter(); model.TotalTagQty = (int)dad.QtyQuery(BrandValue, orgCode, model.Prodect, model.billNo); } model.Brand = BrandValue; JS5_S12_BRAND_INFOTableAdapter BandAd = new JS5_S12_BRAND_INFOTableAdapter(); model.BrandName = BandAd.GetDataByCode(BrandValue).First().BRAND_NAME; model.Month = MonthValue; model.MonthName = m.ToString("yyyy年MM月"); JS5_S12_PRODUCT_TYPE_INFOTableAdapter prdAd = new JS5_S12_PRODUCT_TYPE_INFOTableAdapter(); model.ProdectName = prdAd.GetDataByCode(ProdectValue).First().TREE_NODE_NAME; //查询总共已提交数量 PSIApp psiApp = new PSIApp(); var cents = psiApp.CmList(model.Prodect, MonthValue, model.OrgId, model.Brand); model.TotalCQty = cents.Sum(p => p.cmQty).Value;//psiApp.TotalCmQty(ProdectValue, MonthValue, model.OrgId); model.UserId = UserId; model.subModel = new List <subVModel>(); //查询城市列表 //JS5_S12_SALES_MANAGE_ORG_INFOTableAdapter orgInfo = new JS5_S12_SALES_MANAGE_ORG_INFOTableAdapter(); var orgs = salesApp.getOrginfoByPCode(orgCode, "CITY"); var tagEnts = psiApp.TagList(model.Prodect, MonthValue, model.OrgId, BrandValue); foreach (var org in orgs) { var ent = cents.Where(p => p.orgId.Equals(org.id)); var tagEnt = tagEnts.Find(p => p.orgId.Equals(org.id)); var sales = salesApp.getUserInfoByOrgId(org.id); //if (sales != null) //{ var subModel = new subVModel() { cmQty = ent.Sum(p => p.cmQty).Value, tagQty = tagEnt == null ? 0 : tagEnt.totalTagQty.Value, cityCode = org.id, cityName = org.MANAGE_ORG_NAME, popCode = "", popName = "", }; if (sales != null) { subModel.popCode = sales.id; subModel.popName = sales.Name; } model.subModel.Add(subModel); //} } } return(model); }