public HttpResponseMessage updateDeviceInstance(DM_DEVICE_INSTANCE Param) //CustPageContent { try { device_ins_bo.Update(Param); return(Request.CreateResponse(HttpStatusCode.OK, "更新成功")); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "更新出错:" + ex.Message)); } }
//打开sop public string showSOP(string deviceID) { DM_DEVICE_INSTANCE dM_DEVICE_INSTANCE = _IDM_DEVICE_INSTANCEBO.GetEntityByDeviceID(deviceID);//根据设备id查设备信息 EQM_EQUIP_CLASS_QueryParam param = new EQM_EQUIP_CLASS_QueryParam() { EquipClass = dM_DEVICE_INSTANCE.DeviceName }; IList <EQM_EQUIP_CLASS> EQM_EQUIP_CLASSs = _IEQM_EQUIP_CLASSBO.GetEntities(param); string sopFile = null; if (EQM_EQUIP_CLASSs.Count > 0) { sopFile = EQM_EQUIP_CLASSs[0].SopFile; } return(sopFile); }
public int SynEquipMainData() { //bool middleNew = false; int result = -3; Dictionary <string, List <string> > dictionary = new Dictionary <string, List <string> >(); DateTime now = DateTime.Now; //Guid TypeGuid = Guid.Empty, ClassGuid = Guid.Empty, SpecGuid = Guid.Empty; IList <EQM_EQUIP_TYPE> typedata = null; IList <EQM_EQUIP_CLASS> classdata = null; //获得中间表中获得数据 IList <EQM_SAP_MES_MAIN_DATA> tmpList = eQM_MAIN_DATA.getTempDeviceInstances(); //判断存在未同步的数据 if (tmpList != null && tmpList.Count > 0) { //try //{ using (TransactionScope ts = new TransactionScope()) { //遍历 foreach (EQM_SAP_MES_MAIN_DATA tempIqc in tmpList) { //先判断对应设备编号是否存在 IList <DM_DEVICE_INSTANCE> equpmaindata = dEVICE_INSTANCE_DATA.getexist(tempIqc.EQUNR); #region 台账信息表 //设备编号,设备名称,位置 ,类别 ,等级,固定资产编号,设备规格型号,型号,规格,设备厂商,出厂日期,使用部门,使用人,使用期限,安装日期,投产日期,设备状态 DM_DEVICE_INSTANCE dev = new DM_DEVICE_INSTANCE() { DeviceID = tempIqc.EQUNR, //设备编号 DeviceName = tempIqc.EQKTU, // DeviceType = tempIqc.Attribute02, // 大类 DeviceClass = tempIqc.CLASS, // EQTYP = tempIqc.EQTYP, //设备种类 新增 FixedAssetID = tempIqc.ANLNR, // Model = tempIqc.TYPBZ, // DeviceFirm = tempIqc.ZZGYS, // LiveTime = tempIqc.NDJAR, // DeviceStatus = tempIqc.STAT, // WERK = tempIqc.WERK, // WorkShop = tempIqc.STORT, // DeviceDepartment = tempIqc.ZSYBM, // DeviceUser = tempIqc.ZZSYR, // ABCKZ = tempIqc.ABCKZ, // Standard = tempIqc.ATWRT, // DeviceSpecID = tempIqc.TYPBZ + " " + tempIqc.ATWRT, buildTime = tempIqc.BAUJJ }; if (!string.IsNullOrEmpty(tempIqc.ANSDT)) { dev.ProductionDate = Convert.ToDateTime(tempIqc.ANSDT); } if (!string.IsNullOrEmpty(tempIqc.INBDT)) { dev.StartDate = Convert.ToDateTime(tempIqc.INBDT); } if (equpmaindata.Count == 0) { dEVICE_INSTANCE_DATA.Insert(dev); } else { dEVICE_INSTANCE_DATA.UpdateSome(dev); } #endregion #region 大中小类表 //判定表里是否已经存在改大类 IList <EQM_EQUIP_TYPE> typelist = typeBO.getexist(tempIqc.Attribute02); if (typelist.Count == 0) { //TypeGuid = Guid.NewGuid(); EQM_EQUIP_TYPE type = new EQM_EQUIP_TYPE() { EquipType = tempIqc.Attribute02, }; typeBO.Insert(type); } else //已经存在该设备大类,则根据该条数据的kid进行更新设备大类 { //TypeGuid = Guid.NewGuid(); EQM_EQUIP_TYPE type = new EQM_EQUIP_TYPE() { EquipTypeID = typelist[0].EquipTypeID, EquipType = tempIqc.Attribute02, }; typeBO.UpdateSome(type); } //插入/更新数据后,查询出大类ID typedata = typeBO.getexist(tempIqc.Attribute02); //判断中类表里是否已经存在此中类 IList <EQM_EQUIP_CLASS> classlist = classBO.getexist(tempIqc.EQKTU); if (classlist.Count == 0) { //ClassGuid = Guid.NewGuid(); EQM_EQUIP_CLASS mclass = new EQM_EQUIP_CLASS() { typeKID = typedata[0].EquipTypeID, EquipClass = tempIqc.EQKTU }; classBO.Insert(mclass); } else //已经存在该设备大类,则根据该条数据的kid进行更新设备大类 { EQM_EQUIP_CLASS mclass = new EQM_EQUIP_CLASS() { typeKID = typedata[0].EquipTypeID, EquipClassID = classlist[0].EquipClassID, EquipClass = tempIqc.EQKTU }; classBO.UpdateSome(mclass); } classdata = classBO.getexist(tempIqc.EQKTU); //判断小类表里是否已经存在此小类 IList <EQM_EQUIP_SPEC> speclist = specBO.getexist(tempIqc.ATWRT, tempIqc.TYPBZ); if (speclist.Count == 0) { //ClassGuid = Guid.NewGuid(); EQM_EQUIP_SPEC spec = new EQM_EQUIP_SPEC() { classKID = classdata[0].EquipClassID, //中类ID EquipSpec = tempIqc.TYPBZ + " " + tempIqc.ATWRT //小类 等于规格+型号 }; specBO.Insert(spec); } else { EQM_EQUIP_SPEC spec = new EQM_EQUIP_SPEC() { classKID = classdata[0].EquipClassID, //中类ID EquipSpecID = speclist[0].EquipSpecID, EquipSpec = tempIqc.TYPBZ + " " + tempIqc.ATWRT //小类 等于规格+型号 }; specBO.UpdateSome(spec); } tempIqc.STATE = "1"; //更新中间表 state字段为1 eQM_MAIN_DATA.Update(tempIqc); //log.Info("finish"); #endregion } ts.Complete(); result = 0; //同步成功 } //} //catch (Exception ex) //{ // result = -1; //同步失败 //} } else { result = -2; //没有要同步的数据 } //ILog log = LogManager.GetLogger(typeof(EQM_EQUIP_TYPEController)); return(result); }