public bool addDeviceInformationDao(bean.manageHose hm) { string id; string id0; int flag = 0; string wd1 = "35.0"; string wd2 = "0.0"; string sd1 = "75.0"; string sd2 = "35.0"; string cd = null; string m = null; int ret = 0; String sql = "insert into lb_device_information (id,measureCode,meterNo,terminalname,house_code,housetype,t_high,t_low,h_high,h_low,powerflag,createtime,State) values "; String sql0 = "insert into lb_base_data_home (id,measureCode,meterNo,devtime,temperature,humidity,lng,lat,createDate,warnState,sign,measureMeterCode,warningistrue,carinterval,houseinterval,mcc,measureNo) values "; int num = Int32.Parse(hm.portNumber); string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); for (int j = 0; j < num; j++) { if (j < 10) { if (hm.CommunicationType == "串口通讯协议" || hm.CommunicationType == "TCP协议" || hm.CommunicationType == "云平台协议-01") { if (j + 1 == 10) { m = (j + 1).ToString(); } else { m = "0" + (j + 1).ToString(); } } else { if (hm.CommunicationType == "云平台协议-00") { if (num == 1) { m = "00"; } else { m = "0" + j.ToString(); } } } cd += hm.hostName + "-" + m; } else { if (hm.CommunicationType == "串口通讯协议" || hm.CommunicationType == "TCP协议" || hm.CommunicationType == "云平台协议-01") { m = (j + 1).ToString(); } else { m = j.ToString(); } cd += hm.hostName + "-" + m; } id = Result.GetNewId(); id0 = Result.GetNewId(); int measureNo = System.Math.Abs(id.GetHashCode()); measureNo = Int32.Parse(measureNo.ToString().Substring(0, 5)); if (j > 0) { sql += " ,('" + id + "','" + hm.measureCode + "', '" + m + "', '" + cd + "','" + hm.houseType + "', '" + 0 + "', '" + wd1 + "', '" + wd2 + "', '" + sd1 + "', '" + sd2 + "', '" + flag + "', '" + time + "', '" + hm.State + "')"; sql0 += " , ('" + id0 + "','" + hm.measureCode + "', '" + m + "','" + time + "','0.0','0.0','','','" + time + "','','',CONCAT('" + hm.measureCode + "', '_', '" + m + "'),'','','','0','" + measureNo + "')"; } else { sql += "('" + id + "','" + hm.measureCode + "', '" + m + "', '" + cd + "','" + hm.houseType + "', '" + 0 + "', '" + wd1 + "', '" + wd2 + "', '" + sd1 + "', '" + sd2 + "', '" + flag + "', '" + time + "', '" + hm.State + "')"; sql0 += "('" + id0 + "','" + hm.measureCode + "', '" + m + "','" + time + "','0.0','0.0','','','" + time + "','','',CONCAT('" + hm.measureCode + "', '_', '" + m + "'),'','','','0','" + measureNo + "')"; } cd = null; } ret = DbHelperMySQL.ExecuteSql(sql); if (ret > 0) { ret = DbHelperMySQL.ExecuteSql(sql0); } return(ret == 0 ? false : true); }
public void deleteInvalidData() { String sql1 = " delete from lb_base_data_home where warnState != '1' and warnState != '3' and warningistrue != '1' and warningistrue != '2' and warningistrue != '3' and houseinterval < 1 and carinterval < 1"; DbHelperMySQL.ExecuteSql(sql1); }