DataViewdvRouteN=dbo.ExceSQL(string.Format("SELECT * FROM T_Manage_Task WHERE FCONTROLTASKTYPE =2 and FSTATUS > 0 and FSTARTDEVICE = {0} and FENDDEVICE > 22020 and FENDDEVICE < 22049 and FCurrentLocation < 22019",ManageEnddeviceIndex)).Tables[0].DefaultView;
DataViewdvRouteN=dbo.ExceSQL(string.Format("SELECT * FROM T_Manage_Task WHERE FCONTROLTASKTYPE =2 and FSTATUS > 0 and FSTARTDEVICE = {0} and FENDDEVICE > 22020 and FENDDEVICE < 22052 and FCurrentLocation < 22019",ManageEnddeviceIndex)).Tables[0].DefaultView;
DataViewdvRoutegj=dbo.ExceSQL(string.Format("SELECT * FROM T_Monitor_Task WHERE F_ManageTaskIndex = {0} and F_DeviceIndex >=11001 and F_DeviceIndex <= 11005",manageTaskIdx)).Tables[0].DefaultView;
if(dvRoutegj.Count>0)//
{
DataViewdvRoutejN=dbo.ExceSQL(string.Format("SELECT * FROM T_Manage_Task WHERE FCONTROLTASKTYPE =2 and FSTATUS > 0 and FSTARTDEVICE = {0} and FENDDEVICE > 22020 and FENDDEVICE < 22052 and FCurrentLocation < 22019",Convert.ToInt32(dvRoutegj[0]["F_DeviceIndex"])+7000)).Tables[0].DefaultView;
DataViewdvRouteJ=dbo.ExceSQL(string.Format("SELECT * FROM T_Manage_Task WHERE FCONTROLTASKTYPE =1 and FENDDEVICE = {0} and (FSTARTDEVICE = 22021 or FSTARTDEVICE = 22006 or FSTARTDEVICE = 22012)",ManageStartDeviceIndex)).Tables[0].DefaultView;// and FCurrentLocation < 22019//and FSTATUS > 0
DataViewdvRouteJ=dbo.ExceSQL(string.Format("SELECT * FROM T_Manage_Task WHERE (FCONTROLTASKTYPE =1 and FENDDEVICE = {0} and (FSTARTDEVICE = 22021 or FSTARTDEVICE = 22012 or FSTARTDEVICE = 22006 or FSTARTDEVICE = 22048)) ",ManageStartDeviceIndex)).Tables[0].DefaultView;//or (FSTARTDEVICE = 22006 and FCONTROLTASKTYPE = 4 and FENDDEVICE = {0}) and FCurrentLocation < 22019//and FSTATUS > 0
DataViewdvRouteJN=dbo.ExceSQL("SELECT * FROM T_Manage_Task WHERE ((FSTARTDEVICE = 22006 or FSTARTDEVICE = 22021 or FSTARTDEVICE = 22048)and FCONTROLTASKTYPE = 4 and (FENDDEVICE = 12056 or FENDDEVICE = 12059) and ((FCurrentLocation < 22052 and FCurrentLocation >= 22001) or FCurrentLocation = 0 or FCurrentLocation = 15001))").Tables[0].DefaultView;// and FCurrentLocation < 22019//and FSTATUS > 0
DataViewdvRouteGJN=dbo.ExceSQL(string.Format("SELECT * FROM T_Monitor_Task WHERE (F_DeviceIndex ={1} and F_ManageTaskIndex = {0})",Convert.ToInt32(dvRouteJN[k]["FID"]),devinfo.DeviceIndex)).Tables[0].DefaultView;//or (FSTARTDEVICE = 22006 and FCONTROLTASKTYPE = 4 and FENDDEVICE = {0}) and FCurrentLocation < 22019//and FSTATUS > 0
DataViewdvRouteN=dbo.ExceSQL(string.Format("SELECT * FROM T_Manage_Task WHERE FCONTROLTASKTYPE =2 and FENDDEVICE = {0} and FSTATUS > 0 and FID != {1}",ManageEnddeviceIndex,manageTaskIdx)).Tables[0].DefaultView;// and FCurrentLocation < 22019//and FSTATUS > 0
DataViewdv=dbo.ExceSQL(string.Format("SELECT F_MonitorIndex FROM T_Base_PLC_Ask ,T_Monitor_Task WHERE T_Base_PLC_Ask.F_DeviceIndex = T_Monitor_Task.F_DeviceIndex AND T_Base_PLC_Ask.F_BarCode = T_Monitor_Task.F_TxtParam and (T_Monitor_Task.F_MonitorIndex = {0})",MonitorIndex)).Tables[0].DefaultView;
dbo.ExecuteSql(string.Format("UPDATE T_Manage_Task SET FExceptionNO=NULL WHERE (F_ManageTaskKindIndex ={0}) AND (FID ={1}) and FExceptionNO={2}",obj));
//DataView dv = dbo.ExceSQL(string.Format("SELECT F_MonitorIndex FROM T_Base_PLC_Ask ,T_Monitor_Task WHERE T_Base_PLC_Ask.F_DeviceIndex = T_Monitor_Task.F_DeviceIndex AND T_Base_PLC_Ask.F_BarCode = T_Monitor_Task.F_TxtParam and (T_Monitor_Task.F_MonitorIndex = {0})", MonitorIndex)).Tables[0].DefaultView;
// dbo.ExecuteSql(string.Format("UPDATE T_Manage_Task SET FExceptionNO=NULL WHERE (F_ManageTaskKindIndex ={0}) AND (FID ={1}) and FExceptionNO={2}", obj));
dv=dbo.ExceSQL(string.Format("SELECT F_Remark,F_BindingDevice,F_BarCode FROM T_Base_PLC_Ask WHERE T_Base_PLC_Ask.F_DeviceIndex = {0}",deviceIdx)).Tables[0].DefaultView;
// dv = dbo.ExceSQL(string.Format("SELECT F_Remark,F_BindingDevice,F_BarCode FROM T_Base_PLC_Ask WHERE T_Base_PLC_Ask.F_DeviceIndex = {0}", deviceIdx)).Tables[0].DefaultView;
// if (dv.Count > 0)
// {
// if ((CStaticClass.DeviceErrorAutoModifyRoutePath == "1") && (dv[0]["F_BarCode"].ToString().IndexOf("11111") < 0))
sql.Append("update IO_Control set ERROR_TEXT='").Append(devinfo.DeviceName).Append(",").Append(deviceIdx).Append("条码不正确!").Append("' where CONTROL_ID=").Append(manageTaskIdx);
dboM.ExceSQL(sql.ToString());
}
}
}
//20130709 dbo.ExecuteSql(string.Format("UPDATE T_Base_PLC_Ask SET F_BarCode = '-' WHERE (F_DeviceIndex = {0}) ", deviceIdx));
// sql.Append("update IO_Control set ERROR_TEXT='").Append(devinfo.DeviceName).Append(",").Append(deviceIdx).Append("条码不正确!").Append("' where CONTROL_ID=").Append(manageTaskIdx);
// dboM.ExceSQL(sql.ToString());
// }
// }
//}
//20130709 dbo.ExecuteSql(string.Format("UPDATE T_Base_PLC_Ask SET F_BarCode = '-' WHERE (F_DeviceIndex = {0}) ", deviceIdx));
sbs.Append("select * from IO_CONTROL where (CONTROL_TASK_TYPE = 2) and (CONTROL_STATUS= 0) and (END_DEVICE_CODE = 12059 or END_DEVICE_CODE = 12056) and (substring(START_DEVICE_CODE,1,2)= '13' or substring(START_DEVICE_CODE,1,2)= '14') order by CONTROL_TASK_LEVEL desc,CONTROL_ID asc");
sbs.Append("select * from IO_CONTROL where (CONTROL_TASK_TYPE = 2) and (CONTROL_STATUS= 0) and (END_DEVICE_CODE = 12059 or END_DEVICE_CODE = 12056) and (substring(START_DEVICE_CODE,1,2)= '15' or substring(START_DEVICE_CODE,1,2)= '16'or substring(START_DEVICE_CODE,1,2)= '17'or substring(START_DEVICE_CODE,1,2)= '18') order by CONTROL_TASK_LEVEL desc,CONTROL_ID asc");
sql.Append("select distinct F_RouteID from T_Base_Route_Device where F_DeviceOrder!=-1 and F_DeviceIndex=").Append(devInx);//F_DeviceOrder>0 and 20170927
//sql.Append("select distinct F_RouteID from T_Base_Route_Device where F_DeviceOrder!=-1 and F_DeviceIndex=").Append(devInx);//F_DeviceOrder>0 and 20170927
//sql.Append("select distinct F_RouteID from T_Base_Route_Device where F_DeviceOrder>0 and F_DeviceIndex=").Append(devInx);
sql.Append("select distinct F_RouteID from T_Base_Route_Device where F_DeviceOrder!=-1 and F_DeviceIndex=").Append(devInx);
}
else
{
sql.Append("select distinct F_RouteID from T_Base_Route_Device where F_DeviceIndex=").Append(devInx);
}
//sql.Append("select distinct F_RouteID from T_Base_Route_Device where(F_DeviceOrder!= -1 and F_DeviceIndex = 12888) or ((F_DeviceIndex=12888 or F_DeviceIndex=12066)and F_SerialNumber = 3)
DataViewdvspApply22021=dboMan.ExceSQL(string.Format("select STOCK_BARCODE from IO_CONTROL_APPLY WHERE APPLY_TASK_STATUS < 4 and DEVICE_CODE = {0}",devinfo.DeviceIndex)).Tables[0].DefaultView;
//if (dbo.GetSingle(String.Format("select fid from T_Manage_Task where FENDDEVICE='{0}'", devinfo.DeviceIndex.ToString())) == null)
if((dboMan.GetSingle(String.Format("select END_DEVICE_CODE from IO_CONTROL where END_DEVICE_CODE ='{0}'",devinfo.DeviceIndex.ToString()))==null)&&(dvspApply22021.Count<=0))
{
//dboMan.ExecuteSql(string.Format("INSERT INTO IO_CONTROL_APPLY(CONTROL_APPLY_TYPE,DEVICE_CODE, STOCK_BARCODE, APPLY_TASK_STATUS, CREATE_TIME,WAREHOUSE_CODE,STOCK_HEIGHT)VALUES(IO_CONTROL_APPLY_SEQ.nextval,{0},'{1}','{2}',0,'{4}','{6}','{7}')", ob));
dboMan.ExecuteSql(string.Format("INSERT INTO IO_CONTROL_APPLY(CONTROL_APPLY_TYPE,DEVICE_CODE, STOCK_BARCODE, APPLY_TASK_STATUS, CREATE_TIME)VALUES ({0},'{1}','{2}',{3},'{4}')",ob));
// dvbc = dboMan.ExceSQL(string.Format("SELECT DEVICE_CODE,STOCK_BARCODE FROM IO_CONTROL_APPLY WHERE APPLY_TASK_STATUS<2 and DEVICE_CODE='{0}' and (STOCK_BARCODE = '{1}')", devbind, appbarArray[i].ToString())).Tables[0].DefaultView;
// if (dvbc.Count > 0)
// {
// ifexit = true;
// }
// dvbc = dboMan.ExceSQL(string.Format("select CONTROL_ID from IO_CONTROL where STOCK_BARCODE like '%{0}%'", appbarArray[i].ToString())).Tables[0].DefaultView;
// if (dvbc.Count > 0)
// {
// ifexit = true;
// }
// dvbc = dbo.ExceSQL(string.Format("select fid from T_Manage_Task where FPALLETBARCODE like '%{0}%'", appbarArray[i].ToString())).Tables[0].DefaultView;
dbo.ExecuteSql(string.Format("UPDATE T_Base_PLC_Ask SET F_Time='{0}', F_BarCode = '{1}' WHERE (F_DeviceIndex = {2}) ",DateTime.Now,BoxWeight.ToString(),devidx));
//}
//上报管理当前称重值
DataViewdvspweight=dbo.ExceSQL(string.Format("select F_TaskIndex from T_Base_PLC_Ask WHERE (F_DeviceIndex = {0}) ",devidx)).Tables[0].DefaultView;
if(dvspweight.Count>0)
{
dboMan.ExecuteSql(string.Format("UPDATE IO_CONTROL SET CONTROL_WEIGHT ='{0}' WHERE (CONTROL_ID = {1}) ",BoxWeight.ToString(),Convert.ToInt32(dvspweight[0]["F_TaskIndex"])));
DataViewdvspweight1=dbo.ExceSQL(string.Format("select F_MonitorIndex from T_Monitor_Task WHERE (F_DeviceIndex = {0} and F_ManageTaskIndex = {1}) ",devidx,Convert.ToInt32(dvspweight[0]["F_TaskIndex"]))).Tables[0].DefaultView;
DataViewdvspApply16=dboMan.ExceSQL(string.Format("select STOCK_BARCODE from IO_CONTROL_APPLY WHERE APPLY_TASK_STATUS < 2 and DEVICE_CODE = {0}",dcode)).Tables[0].DefaultView;
dvspApply16=dboMan.ExceSQL(string.Format("select STOCK_BARCODE from IO_CONTROL_APPLY WHERE APPLY_TASK_STATUS < 4 and DEVICE_CODE = {0}",dcode)).Tables[0].DefaultView;
dvspHave16=dbo.ExceSQL(string.Format("select FENDDEVICE from T_MANAGE_TASK WHERE FENDDEVICE = {0}",dcode)).Tables[0].DefaultView;
}
//else if (devidx == 220661)
//{
// dvspApply16 = dboMan.ExceSQL(string.Format("select STOCK_BARCODE from IO_CONTROL_APPLY WHERE APPLY_TASK_STATUS < 4 and DEVICE_CODE = {0}", dcode)).Tables[0].DefaultView;
// dvspHave16 = dbo.ExceSQL(string.Format("select FSTARTDEVICE from T_MANAGE_TASK WHERE FSTARTDEVICE = {0} and FSTATUS = 0", dcode)).Tables[0].DefaultView;
//}
else//其余托盘垛入库申请
{
dvspApply16=dboMan.ExceSQL(string.Format("select STOCK_BARCODE from IO_CONTROL_APPLY WHERE APPLY_TASK_STATUS < 2 and DEVICE_CODE = {0}",dcode)).Tables[0].DefaultView;
dvspHave16=dbo.ExceSQL(string.Format("select FSTARTDEVICE from T_MANAGE_TASK WHERE FSTARTDEVICE = {0} and FSTATUS = 0",dcode)).Tables[0].DefaultView;
dvspRG2=dbo.ExceSQL(string.Format("select FSTARTDEVICE from T_Manage_Task WHERE (FSTARTDEVICE = {0} and ((FCurrentLocation < 22019 and FCurrentLocation >=22001)or FCurrentLocation = 0 or FCurrentLocation = 15001)) ",devinfoT.DeviceIndex)).Tables[0].DefaultView;
}
dvspRG2=dbo.ExceSQL(string.Format("select F_NumParam1 from T_Monitor_Task WHERE (F_DeviceIndex = 15001 and F_NumParam1 = {0} and F_DeviceCommandIndex = 2) ",tempdeviceindex.ToString().Substring(0,5))).Tables[0].DefaultView;
else
{
dvspRG2=dbo.ExceSQL(string.Format("select FSTARTDEVICE from T_Manage_Task WHERE (FSTARTDEVICE = {0}) ",devinfoT.DeviceIndex)).Tables[0].DefaultView;
}//dvspRG2 = dbo.ExceSQL(string.Format("select F_NumParam1 from T_Monitor_Task WHERE (F_DeviceIndex = 15001 and F_NumParam1 = {0} and F_DeviceCommandIndex = 2) ", tempdeviceindex.ToString().Substring(0, 5))).Tables[0].DefaultView;