public IHttpActionResult QueryMachine_CustomerByuidAPI(int Machine_Customer_UID) { //获取仓库 var war = machineYieldReportService.QueryMachine_Customer(Machine_Customer_UID)[0]; //获取储位 var storages = machineYieldReportService.QueryStations(Machine_Customer_UID); var result = new Machine_CustomerAndStationDTO { Machine_Customer_UID = war.Machine_Customer_UID, Plant_Organization_UID = war.Plant_Organization_UID, Plant_Organization = war.Plant_Organization, BG_Organization_UID = war.BG_Organization_UID, BG_Organization = war.BG_Organization, FunPlant_Organization_UID = war.FunPlant_Organization_UID, FunPlant_Organization = war.FunPlant_Organization, MES_Customer_Name = war.MES_Customer_Name, PIS_Customer_Name = war.PIS_Customer_Name, Is_Enable = war.Is_Enable, Createder = war.Createder, Created_UID = war.Created_UID, Created_Date = war.Created_Date, Modifieder = war.Modifieder, Modified_UID = war.Modified_UID, Modified_Date = war.Modified_Date, DataSourceType = war.DataSourceType, Storages = storages }; return(Ok(result)); }
public string AddOrEditCustomerAndStationInfo(Machine_CustomerAndStationDTO dto) { try { var warehouse = machine_CustomerRepository.GetById(dto.Machine_Customer_UID); if (warehouse != null) { var ware = machine_CustomerRepository.GetById(dto.Machine_Customer_UID); ware.Plant_Organization_UID = dto.Plant_Organization_UID; ware.BG_Organization_UID = dto.BG_Organization_UID; ware.FunPlant_Organization_UID = dto.FunPlant_Organization_UID; ware.PIS_Customer_Name = dto.PIS_Customer_Name; ware.MES_Customer_Name = dto.MES_Customer_Name; ware.Is_Enable = dto.Is_Enable.Value; //ware.Created_Date = DateTime.Now; //ware.Created_UID = dto.Created_UID; ware.Modified_UID = dto.Modified_UID; ware.Modified_Date = DateTime.Now; ware.DataSourceType = dto.DataSourceType; machine_CustomerRepository.Update(ware); unitOfWork.Commit(); } else { Machine_Customer ware = new Machine_Customer(); ware.Plant_Organization_UID = dto.Plant_Organization_UID; ware.BG_Organization_UID = dto.BG_Organization_UID; ware.FunPlant_Organization_UID = dto.FunPlant_Organization_UID; ware.PIS_Customer_Name = dto.PIS_Customer_Name; ware.MES_Customer_Name = dto.MES_Customer_Name; ware.Is_Enable = dto.Is_Enable.Value; ware.Created_Date = DateTime.Now; ware.Created_UID = dto.Created_UID; ware.Modified_UID = dto.Modified_UID; ware.Modified_Date = DateTime.Now; ware.DataSourceType = dto.DataSourceType; machine_CustomerRepository.Add(ware); unitOfWork.Commit(); } foreach (var item in dto.Storages) { if (dto.Machine_Customer_UID == 0) { var war = machine_CustomerRepository.GetFirstOrDefault(m => m.BG_Organization_UID == dto.BG_Organization_UID && m.Plant_Organization_UID == dto.Plant_Organization_UID && m.MES_Customer_Name == dto.MES_Customer_Name && m.PIS_Customer_Name == dto.PIS_Customer_Name); dto.Machine_Customer_UID = war.Machine_Customer_UID; } if (item.Machine_Station_UID == 0) { Machine_Station ws = new Machine_Station(); ws.Plant_Organization_UID = dto.Plant_Organization_UID; ws.BG_Organization_UID = dto.BG_Organization_UID; ws.FunPlant_Organization_UID = dto.FunPlant_Organization_UID; ws.Machine_Customer_UID = dto.Machine_Customer_UID; ws.PIS_Station_Name = item.PIS_Station_Name; ws.MES_Station_Name = item.MES_Station_Name; ws.Is_Enable = item.Is_Enable; ws.Created_Date = DateTime.Now; ws.Created_UID = dto.Created_UID; ws.Modified_UID = dto.Modified_UID; ws.Modified_Date = DateTime.Now; var hasdata = machine_StationRepository.GetFirstOrDefault(m => m.Machine_Customer_UID == ws.Machine_Customer_UID && m.PIS_Station_Name == ws.PIS_Station_Name && m.MES_Station_Name == ws.MES_Station_Name); if (hasdata != null) { return("更新站点信息失败:已经存在,不可重复添加"); } machine_StationRepository.Add(ws); unitOfWork.Commit(); } else { var warehousestorate = machine_StationRepository.GetById(item.Machine_Station_UID); warehousestorate.Plant_Organization_UID = dto.Plant_Organization_UID; warehousestorate.BG_Organization_UID = dto.BG_Organization_UID; warehousestorate.FunPlant_Organization_UID = dto.FunPlant_Organization_UID; warehousestorate.Machine_Customer_UID = dto.Machine_Customer_UID; warehousestorate.PIS_Station_Name = item.PIS_Station_Name; warehousestorate.MES_Station_Name = item.MES_Station_Name; warehousestorate.Is_Enable = item.Is_Enable; //warehousestorate.Created_Date = DateTime.Now; //warehousestorate.Created_UID = dto.Created_UID; warehousestorate.Modified_UID = dto.Modified_UID; warehousestorate.Modified_Date = DateTime.Now; machine_StationRepository.Update(warehousestorate); unitOfWork.Commit(); } } return("SUCCESS"); } catch (Exception e) { return("更新专案信息失败:" + e.Message); } }