public AscmDeliBatSumMain(AscmDeliBatSumMain ascmDeliBatSumMain, string supplierDocNumber, string supplierName, string driverSn) { GetOwner(ascmDeliBatSumMain); this.supplierDocNumberCn = supplierDocNumber; this.supplierNameCn = supplierName; this.driverSnCn = driverSn; }
public AscmDeliBatSumMain(AscmDeliBatSumMain ascmDeliBatSumMain, string supplierDocNumber, string supplierName, Int64 containerQuantity, Int64 checkContainerQuantity, decimal totalQuantity, decimal checkQuantity, decimal containerBindQuantity) { GetOwner(ascmDeliBatSumMain); this.supplierDocNumberCn = supplierDocNumber; this.supplierNameCn = supplierName; this.containerQuantity = containerQuantity; this.checkContainerQuantity = checkContainerQuantity; this.totalQuantity = totalQuantity; this.checkQuantity = checkQuantity; this.containerBindQuantity = containerBindQuantity; }
public void Delete(AscmDeliBatSumMain ascmDeliBatSumMain) { try { YnDaoHelper.GetInstance().nHibernateHelper.Delete<AscmDeliBatSumMain>(ascmDeliBatSumMain); } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("删除失败(Delete AscmDeliBatSumMain)", ex); throw ex; } }
public AscmDeliBatSumMain(AscmDeliBatSumMain ascmDeliBatSumMain, decimal totalNumber, decimal inWarehouseContainerBindNumber, decimal containerBindNumber, decimal palletBindNumber, decimal driverBindNumber, long containerNumber, long inWarehouseContainerNumber, long deliBatNumber) { GetOwner(ascmDeliBatSumMain); this.totalNumber = totalNumber; this.inWarehouseContainerBindNumber = inWarehouseContainerBindNumber; this.containerBindNumber = containerBindNumber; this.palletBindNumber = palletBindNumber; this.driverBindNumber = driverBindNumber; this.containerNumber = containerNumber; this.inWarehouseContainerNumber = inWarehouseContainerNumber; this.deliBatNumber = deliBatNumber; }
public void GetOwner(AscmDeliBatSumMain ascmDeliBatSumMain) { this.id = ascmDeliBatSumMain.id; this.docNumber = ascmDeliBatSumMain.docNumber; this.organizationId = ascmDeliBatSumMain.organizationId; this.createUser = ascmDeliBatSumMain.createUser; this.createTime = ascmDeliBatSumMain.createTime; this.modifyUser = ascmDeliBatSumMain.modifyUser; this.modifyTime = ascmDeliBatSumMain.modifyTime; this.supplierId = ascmDeliBatSumMain.supplierId; this.driverId = ascmDeliBatSumMain.driverId; this.status = ascmDeliBatSumMain.status; this.appointmentStartTime = ascmDeliBatSumMain.appointmentStartTime; this.appointmentEndTime = ascmDeliBatSumMain.appointmentEndTime; this.confirmor = ascmDeliBatSumMain.confirmor; this.confirmTime = ascmDeliBatSumMain.confirmTime; this.toPlantTime = ascmDeliBatSumMain.toPlantTime; this.receiver = ascmDeliBatSumMain.receiver; this.acceptTime = ascmDeliBatSumMain.acceptTime; this.warehouseId = ascmDeliBatSumMain.warehouseId; }
public ContentResult SupplierDeliveryBatSumMainSave(AscmDeliBatSumMain ascmDeliBatSumMain_Model, int? id) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { string userId = string.Empty; if (User.Identity.IsAuthenticated) userId = User.Identity.Name; if (string.IsNullOrEmpty(userId)) throw new Exception("用户错误!"); AscmUserInfo ascmUserInfo = AscmUserInfoService.GetInstance().Get(userId); if (ascmUserInfo.extExpandType != "erp") throw new Exception("供应商用户错误!"); AscmUserInfoService.GetInstance().SetSupplier(ascmUserInfo); if (ascmUserInfo.ascmSupplier == null) throw new Exception("供应商用户错误!"); AscmDeliBatSumMain ascmDeliBatSumMain = null; if (id.HasValue) { ascmDeliBatSumMain = AscmDeliBatSumMainService.GetInstance().Get(id.Value); if (ascmDeliBatSumMain == null) throw new Exception("保存供应商送货合单失败"); if (ascmDeliBatSumMain.status != AscmDeliBatSumMain.StatusDefine.unConfirm) throw new Exception("供应商送货合单状态错误"); ascmDeliBatSumMain.modifyUser = userId; ascmDeliBatSumMain.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); } else { ////2013.11.28 ////一张司机卡和一个子库一次只能生成一张合单,在该合单被美的接收后才允许绑定第二张合单 //List<AscmDeliBatSumMain> listAscmDeliBatSumMain = AscmDeliBatSumMainService.GetInstance().GetList("from AscmDeliBatSumMain where driverId=" + ascmDeliBatSumMain_Model.driverId + " and status='" + AscmDeliBatSumMain.StatusDefine.unConfirm + "' and warehouseId='" + ascmDeliBatSumMain_Model.warehouseId+"'"); //if (listAscmDeliBatSumMain.Count>0) // throw new Exception("一张司机卡和一个子库一次只能生成一张合单,在该合单被美的接收后才允许绑定第二张合单"); ascmDeliBatSumMain = new AscmDeliBatSumMain(); int maxId = AscmDeliBatSumMainService.GetInstance().GetMaxId(); ascmDeliBatSumMain.id = ++maxId; //2014-1-2 根据业务要求合单号与条码号统一 //ascmDeliBatSumMain.docNumber = YnFrame.Services.YnBillKeyService.GetInstance().GetBillKey("AscmDeliBatSumMain" + ascmUserInfo.ascmSupplier.id, "", "yyyyMMdd", 2); //ascmDeliBatSumMain.barcode = YnFrame.Services.YnBillKeyService.GetInstance().GetBillKey("AscmDeliBatSumMainBarcode", "", "", 9); ascmDeliBatSumMain.docNumber = YnFrame.Services.YnBillKeyService.GetInstance().GetBillKey("AscmDeliBatSumMain", "HD", "yyMMdd", 5); ascmDeliBatSumMain.barcode = ascmDeliBatSumMain.docNumber; ascmDeliBatSumMain.createUser = userId; ascmDeliBatSumMain.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); ascmDeliBatSumMain.modifyUser = userId; ascmDeliBatSumMain.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); ascmDeliBatSumMain.status = AscmDeliBatSumMain.StatusDefine.unConfirm; } ascmDeliBatSumMain.warehouseId = ascmDeliBatSumMain_Model.warehouseId; ascmDeliBatSumMain.supplierId = ascmUserInfo.ascmSupplier.id; ascmDeliBatSumMain.driverId = ascmDeliBatSumMain_Model.driverId; if (id.HasValue) AscmDeliBatSumMainService.GetInstance().Update(ascmDeliBatSumMain); else AscmDeliBatSumMainService.GetInstance().Save(ascmDeliBatSumMain); jsonObjectResult.result = true; jsonObjectResult.id = ascmDeliBatSumMain.id.ToString(); jsonObjectResult.message = ""; } catch (Exception ex) { jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public DeliveryBatSumMain GetDeliveryBatSumMain(AscmDeliBatSumMain main) { DeliveryBatSumMain deliveryBatSumMain = null; if (main != null) { deliveryBatSumMain = new DeliveryBatSumMain(); deliveryBatSumMain.id = main.id; deliveryBatSumMain.docNumber = main.docNumber == null ? string.Empty : main.docNumber; deliveryBatSumMain.supplierShortName = main.supplierNameCn == null ? string.Empty : main.supplierNameCn; deliveryBatSumMain.supplierDocNumber = main.supplierDocNumberCn == null ? string.Empty : main.supplierDocNumberCn; deliveryBatSumMain.driverSn = main.driverSnCn == null ? string.Empty : main.driverSnCn; deliveryBatSumMain.warehouse = main.warehouseId == null ? string.Empty : main.warehouseId; deliveryBatSumMain.deliveryPlace = string.Empty; deliveryBatSumMain.appointmentStartTime = main.appointmentStartTimeShow; deliveryBatSumMain.appointmentEndTime = main.appointmentEndTimeShow; deliveryBatSumMain.containers = 0; deliveryBatSumMain.listContainerQuantity = new List<long>(); deliveryBatSumMain.listContainerSpec = new List<string>(); deliveryBatSumMain.listContainerDescription = new List<string>(); deliveryBatSumMain.status = main.statusCn == null ? string.Empty : main.statusCn; deliveryBatSumMain.supplierShortName = MideaAscm.Security.Utility.GetSubString(deliveryBatSumMain.supplierShortName, 16); } return deliveryBatSumMain; }
public void Save(AscmDeliBatSumMain ascmDeliBatSumMain) { try { using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) { try { YnDaoHelper.GetInstance().nHibernateHelper.Save(ascmDeliBatSumMain); tx.Commit();//正确执行提交 } catch (Exception ex) { tx.Rollback();//回滚 throw ex; } } } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("保存失败(Save AscmDeliBatSumMain)", ex); throw ex; } }
public void GetSupplierUnloadingPoint(AscmDeliBatSumMain ascmDeliBatSumMain) { try { bool isOnTime = true; DateTime dtServerTime = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentDate("AscmDeliBatSumMain"); DateTime beginTime = DateTime.Now, endTime = DateTime.Now; if (DateTime.TryParse(ascmDeliBatSumMain.appointmentStartTime, out beginTime)) { //早于最早到货时间 if (dtServerTime.CompareTo(beginTime) < 0) { isOnTime = false; } } if (DateTime.TryParse(ascmDeliBatSumMain.appointmentEndTime, out endTime)) { //晚于最晚到货时间 if (dtServerTime.CompareTo(endTime) > 0) { isOnTime = false; } } ascmDeliBatSumMain.isOnTime = isOnTime; string sql = "from AscmUnloadingPoint"; string where = string.Empty; string whereWarehouse = "warehouseId in(select warehouseId from AscmDeliveryOrderBatch where id in({0}))"; whereWarehouse = string.Format(whereWarehouse, "select batchId from AscmDeliBatSumDetail where mainId=" + ascmDeliBatSumMain.id); where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereWarehouse); if (!string.IsNullOrEmpty(where)) { sql += " where " + where; } IList<AscmUnloadingPoint> ilist = YnDaoHelper.GetInstance().nHibernateHelper.Find<AscmUnloadingPoint>(sql); if (ilist != null && ilist.Count > 0) { List<AscmUnloadingPoint> list = YnBaseClass2.Helper.ConvertHelper.ConvertIListToList<AscmUnloadingPoint>(ilist); //分配卸货点 AscmUnloadingPoint ascmUnloadingPoint = list.Find(P => P.status == AscmUnloadingPoint.StatusDefine.idle); if (ascmUnloadingPoint != null) { //更改卸货点状态为“预定” ascmUnloadingPoint.status = AscmUnloadingPoint.StatusDefine.reserve; dtServerTime = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentDate("AscmDeliBatSumMain"); ascmUnloadingPoint.modifyTime = dtServerTime.ToString("yyyy-MM-dd HH:mm:ss"); YnDaoHelper.GetInstance().nHibernateHelper.Update(ascmUnloadingPoint); //为入厂供应商车辆预分配一个卸货点,同时列出其它卸货点的使用情况 ascmDeliBatSumMain.unloadingPointName = ascmUnloadingPoint.name; } ascmDeliBatSumMain.listUnloadingPoint = list; } } catch (Exception ex) { throw ex; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //提取数据 int id = 0; string containerSpAndQuantity = ""; //出货子库 string supplyWarehouse = ""; //送货地点 string deliveryPlace = ""; AscmDeliBatSumMain ascmDeliBatSumMain = new AscmDeliBatSumMain(); List<AscmDeliBatSumDetail> listAscmDeliBatSumDetail = new List<AscmDeliBatSumDetail>(); if (!string.IsNullOrEmpty(Request.QueryString["id"]) && int.TryParse(Request.QueryString["id"], out id)) { //ascmDeliBatSumMain = AscmDeliBatSumMainService.GetInstance().Get(id); //ascmDeliBatSumMain.ascmSupplier = AscmSupplierService.GetInstance().Get(ascmDeliBatSumMain.supplierId); //ascmDeliBatSumMain.ascmDriver = AscmDriverService.GetInstance().Get(ascmDeliBatSumMain.driverId); //供方简称 string supplierShortName = "select vendorSiteCode from AscmSupplierAddress a where a.vendorSiteCodeAlt=s.docNumber and rownum=1"; //司机编号 string driverSn = "select sn from AscmDriver d where d.id=h.driverId"; string hql = string.Format("select new AscmDeliBatSumMain(h,s.docNumber,({0}),({1})) from AscmDeliBatSumMain h,AscmSupplier s", supplierShortName, driverSn); string where = string.Empty; where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "h.supplierId=s.id"); where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "h.id=" + id); hql += " where " + where; ascmDeliBatSumMain = AscmDeliBatSumMainService.GetInstance().Get(hql); //List<AscmDeliBatSumDetail> list = AscmDeliBatSumDetailService.GetInstance().GetListByMainId(id); //容器绑定数量 string containerBindNumber = "select sum(quantity) from AscmContainerDelivery where deliveryOrderBatchId=l.batchId and batSumMainId=l.mainId"; //容器数量 string containerNumber = "select count(distinct containerSn) from AscmContainerDelivery where deliveryOrderBatchId=l.batchId and batSumMainId=l.mainId"; hql = string.Format("select new AscmDeliBatSumDetail(l,({0}),0M,0M,({1})) from AscmDeliBatSumDetail l", containerBindNumber, containerNumber); where = string.Empty; where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, " mainId=" + id); hql += " where " + where; List<AscmDeliBatSumDetail> list = AscmDeliBatSumDetailService.GetInstance().GetList(hql); AscmDeliBatSumDetailService.GetInstance().SetDeliveryOrderBatch(list, true); AscmDeliBatSumDetailService.GetInstance().SetMaterial(list); string warehouseId = Request.QueryString["warehouseId"]; string materialCode = Request.QueryString["materialCode"]; if (list != null && list.Count > 0) { //设置作业 AscmDeliBatSumDetailService.GetInstance().SetWipEntityName(list); supplyWarehouse = list.Where(P => !string.IsNullOrEmpty(P.batchSupperWarehouse)).FirstOrDefault().batchSupperWarehouse; deliveryPlace = list.Where(P=>!string.IsNullOrEmpty(P.batchWipLine)).FirstOrDefault().batchWipLine; string containerSns = ""; bool isWarehouseId = true, isMaterialCode = true; List<AscmContainerDelivery> listAscmContainerDelivery = AscmContainerDeliveryService.GetInstance().GetListByDeliverySumMainId(id, false); List<AscmContainerDelivery> _listAscmContainerDelivery = new List<AscmContainerDelivery>(); foreach (AscmDeliBatSumDetail detail in list) { isWarehouseId = isMaterialCode = true; if (warehouseId != null && warehouseId.Trim() != "") isWarehouseId = detail.batchWarehouseId == warehouseId.Trim(); if (materialCode != null && materialCode.Trim() != "") isMaterialCode = !string.IsNullOrEmpty(detail.materialDocNumber) && detail.materialDocNumber.Substring(0, 4) == materialCode.Trim(); if (isWarehouseId && isMaterialCode) { listAscmDeliBatSumDetail.Add(detail); if (listAscmContainerDelivery != null) { foreach (AscmContainerDelivery delivery in listAscmContainerDelivery) { if (delivery.deliveryOrderBatchId == detail.batchId && delivery.materialId == detail.materialId) { if (containerSns != "") containerSns += ","; containerSns += "'" + delivery.containerSn + "'"; _listAscmContainerDelivery.Add(delivery); } } } } } if (containerSns != "") { List<AscmContainer> listAscmContainer = AscmContainerService.GetInstance().GetList("from AscmContainer where sn in(" + containerSns + ")", false, true); var groupByAscmContainerSpec = listAscmContainer.GroupBy(P => P.spec); foreach (IGrouping<string, AscmContainer> igSpec in groupByAscmContainerSpec) { int specCount = 0; foreach (AscmContainer ascmContainer in igSpec) { specCount += _listAscmContainerDelivery.Where(p => p.containerSn == ascmContainer.sn).Select(item => item.containerSn).Distinct().Count(); } if (containerSpAndQuantity != "") containerSpAndQuantity += " "; containerSpAndQuantity += string.Format("{0}:{1}", igSpec.Key, specCount); } } int i = 0; listAscmDeliBatSumDetail = listAscmDeliBatSumDetail.OrderBy(P => P.batchBarCode).ToList(); foreach (AscmDeliBatSumDetail detail in listAscmDeliBatSumDetail) { detail.barcode = ascmDeliBatSumMain.docNumber + (Math.Floor(i / 7M) + 1); detail.barcodeShow = Code.BarCode128.GetBarcode(detail.barcode); i++; } } } ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = Server.MapPath("SupplierDriverDeliveryReport.rdlc"); ReportDataSource rds1 = new ReportDataSource(); rds1.Name = "DataSet1"; rds1.Value = listAscmDeliBatSumDetail; ReportViewer1.LocalReport.DataSources.Clear();//好像不clear也可以 ReportViewer1.LocalReport.DataSources.Add(rds1); string companpyTitle = "美的中央空调"; string title = companpyTitle + "供应商送货合单"; ReportParameter[] reportParameters = new ReportParameter[] { new ReportParameter("ReportParameter_Title", title), new ReportParameter("ReportParameter_ReportTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm")), new ReportParameter("ReportParameter_SupplierName", ascmDeliBatSumMain.supplierNameCn), new ReportParameter("ReportParameter_SupplierDocNumber", ascmDeliBatSumMain.supplierDocNumberCn), new ReportParameter("ReportParameter_DocNumber", ascmDeliBatSumMain.docNumber), new ReportParameter("ReportParameter_DriverSn", ascmDeliBatSumMain.driverSnCn), new ReportParameter("ReportParameter_DriverPlateNumber", ascmDeliBatSumMain.driverPlateNumber), new ReportParameter("ReportParameter_DeliveryPlace", deliveryPlace), new ReportParameter("ReportParameter_AppointmentStartTime", ascmDeliBatSumMain.appointmentStartTimeShow), new ReportParameter("ReportParameter_AppointmentEndTime", ascmDeliBatSumMain.appointmentEndTimeShow), new ReportParameter("ReportParameter_Status", ascmDeliBatSumMain.statusCn), new ReportParameter("ReportParameter_Warehouse", ascmDeliBatSumMain.warehouseId), new ReportParameter("ReportParameter_SupplyWarehouse", supplyWarehouse), new ReportParameter("ReportParameter_ContainerSpAndQuantity", containerSpAndQuantity) }; ReportViewer1.LocalReport.SetParameters(reportParameters); ReportViewer1.LocalReport.Refresh(); } }