NBUserManageService.cs 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138
  1. using LeaRun.Application.Entity.NBManage;
  2. using LeaRun.Data;
  3. using LeaRun.Util;
  4. using LeaRun.Util.WebControl;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Data;
  10. using System.Threading.Tasks;
  11. using System.Diagnostics;
  12. using Newtonsoft.Json.Linq;
  13. using LeaRun.Util.Log;
  14. using LeaRun.Application.Code;
  15. namespace LeaRun.Application.Service.NBManage
  16. {
  17. /// <summary>
  18. /// 用户管理
  19. /// </summary>
  20. public class NBUserManageService
  21. {
  22. SqlHelper sqlHelper = new SqlHelper("NBDB");
  23. Log log = LogFactory.GetLogger(typeof(NBUserManageService));
  24. #region 获取用户列表
  25. /// <summary>
  26. /// 获取用户列表
  27. /// </summary>
  28. /// <param name="pagination"></param>
  29. /// <param name="keyword"></param>
  30. /// <param name="searchType"></param>
  31. /// <param name="id"></param>
  32. /// <param name="level"></param>
  33. /// <returns></returns>
  34. public string GetNBUserList(Pagination pagination, string keyword, string searchType, string id, string level)
  35. {
  36. if ("".Equals(id) && "".Equals(keyword))
  37. {
  38. return GETNoInfo(pagination);
  39. }
  40. return GetMeterInfo(pagination, keyword, id, level);
  41. }
  42. #endregion
  43. #region 没有数据的时候返回的数据
  44. /// <summary>
  45. /// 没有数据的时候返回的数据
  46. /// </summary>
  47. /// <param name="pagination"></param>
  48. /// <returns></returns>
  49. private string GETNoInfo(Pagination pagination)
  50. {
  51. var watch = CommonHelper.TimerStart();
  52. var JsonData = new
  53. {
  54. rows = "",
  55. total = pagination.total,
  56. page = pagination.page,
  57. records = pagination.records,
  58. costtime = CommonHelper.TimerEnd(watch)
  59. };
  60. return JsonData.ToJson();
  61. }
  62. #endregion
  63. #region 获取区域信息 废弃
  64. /// <summary>
  65. /// 获取区域信息
  66. /// </summary>
  67. /// <returns></returns>
  68. private string GetAreaInfo(Pagination pagination, string keyword, string id, string level)
  69. {
  70. string whereSql = GetLevel(level, id);
  71. var watch = CommonHelper.TimerStart();
  72. StringBuilder where = new StringBuilder(whereSql);
  73. StringBuilder sb = new StringBuilder();
  74. string leftJoinString = " from RMRS_AreaInfo A left join RMRS_BldgInfo B on A.AreaID = B.AreaID left join RMRS_ApmtInfo T on B.BldgID = T.BldgID left join RMRS_RoomInfo R on R.ApmtID = T.ApmtID left join RMRS_MeterInfo M on M.RoomID = R.RoomID ";
  75. //if (!"".Equals(keyword))
  76. //{
  77. // sb.Append(" and (R.RoomNo like '%").Append(keyword + "%' or R.RoomName like '%").Append(keyword + "%')");
  78. //}
  79. string sql = " select count(1) " + leftJoinString + where;
  80. pagination.records = Convert.ToInt32(sqlHelper.ExecuteScalar(sql, CommandType.Text, null));
  81. int start = (pagination.page - 1) * pagination.rows + 1;
  82. int end = pagination.page * pagination.rows;
  83. sql = "SELECT PageTable.AreaID, PageTable.AreaName FROM " +
  84. "( " +
  85. "SELECT " +
  86. " ROW_NUMBER() OVER(ORDER BY RoomID) AS RowIndex," +
  87. " * " +
  88. "FROM " +
  89. " (select A.AreaID, A.AreaName, B.BldgID, B.BldgNo, B.BldgName, T.ApmtID, T.ApmtNo, T.ApmtName, R.RoomID, R.RoomNo, R.RoomName, R.UserNo, R.UserName, M.MeterID, M.ElecAddress " +
  90. leftJoinString + where + ") as mytable " +
  91. " )" +
  92. " AS PageTable " +
  93. " WHERE RowIndex BETWEEN " + start + " AND " + end;
  94. return GetData(watch, pagination, sql);
  95. }
  96. #endregion
  97. #region 获取楼宇信息 废弃
  98. /// <summary>
  99. /// 获取楼宇信息
  100. /// </summary>
  101. /// <returns></returns>
  102. private string GetBldgInfo(Pagination pagination, string keyword, string id, string level)
  103. {
  104. string whereSql = GetLevel(level, id);
  105. var watch = CommonHelper.TimerStart();
  106. StringBuilder where = new StringBuilder(whereSql);
  107. StringBuilder sb = new StringBuilder();
  108. string leftJoinString = " from RMRS_AreaInfo A left join RMRS_BldgInfo B on A.AreaID = B.AreaID left join RMRS_ApmtInfo T on B.BldgID = T.BldgID left join RMRS_RoomInfo R on R.ApmtID = T.ApmtID left join RMRS_MeterInfo M on M.RoomID = R.RoomID ";
  109. //if (!"".Equals(keyword))
  110. //{
  111. // sb.Append(" and (R.RoomNo like '%").Append(keyword + "%' or R.RoomName like '%").Append(keyword + "%')");
  112. //}
  113. string sql = " select count(1) " + leftJoinString + where;
  114. pagination.records = Convert.ToInt32(sqlHelper.ExecuteScalar(sql, CommandType.Text, null));
  115. int start = (pagination.page - 1) * pagination.rows + 1;
  116. int end = pagination.page * pagination.rows;
  117. sql = "SELECT PageTable.AreaID, PageTable.AreaName, PageTable.BldgID, PageTable.BldgNo, PageTable.BldgName FROM " +
  118. "( " +
  119. "SELECT " +
  120. " ROW_NUMBER() OVER(ORDER BY RoomID) AS RowIndex," +
  121. " * " +
  122. "FROM " +
  123. " (select A.AreaID, A.AreaName, B.BldgID, B.BldgNo, B.BldgName, T.ApmtID, T.ApmtNo, T.ApmtName, R.RoomID, R.RoomNo, R.RoomName, R.UserNo, R.UserName, M.MeterID, M.ElecAddress " +
  124. leftJoinString + where + ") as mytable " +
  125. " )" +
  126. " AS PageTable " +
  127. " WHERE RowIndex BETWEEN " + start + " AND " + end;
  128. return GetData(watch, pagination, sql);
  129. }
  130. #endregion
  131. #region 获取单元信息 废弃
  132. /// <summary>
  133. /// 获取单元信息
  134. /// </summary>
  135. /// <returns></returns>
  136. private string GetApmtInfo(Pagination pagination, string keyword, string id, string level)
  137. {
  138. string whereSql = GetLevel(level, id);
  139. var watch = CommonHelper.TimerStart();
  140. StringBuilder where = new StringBuilder(whereSql);
  141. StringBuilder sb = new StringBuilder();
  142. string leftJoinString = " from RMRS_AreaInfo A left join RMRS_BldgInfo B on A.AreaID = B.AreaID left join RMRS_ApmtInfo T on B.BldgID = T.BldgID left join RMRS_RoomInfo R on R.ApmtID = T.ApmtID left join RMRS_MeterInfo M on M.RoomID = R.RoomID ";
  143. //if (!"".Equals(keyword))
  144. //{
  145. // sb.Append(" and (R.RoomNo like '%").Append(keyword + "%' or R.RoomName like '%").Append(keyword + "%')");
  146. //}
  147. string sql = " select count(1) " + leftJoinString + where;
  148. pagination.records = Convert.ToInt32(sqlHelper.ExecuteScalar(sql, CommandType.Text, null));
  149. int start = (pagination.page - 1) * pagination.rows + 1;
  150. int end = pagination.page * pagination.rows;
  151. sql = "SELECT PageTable.AreaID, PageTable.AreaName, PageTable.BldgID, PageTable.BldgNo, PageTable.BldgName, PageTable.ApmtID, PageTable.ApmtNo, PageTable.ApmtName FROM " +
  152. "( " +
  153. "SELECT " +
  154. " ROW_NUMBER() OVER(ORDER BY RoomID) AS RowIndex," +
  155. " * " +
  156. "FROM " +
  157. " (select A.AreaID, A.AreaName, B.BldgID, B.BldgNo, B.BldgName, T.ApmtID, T.ApmtNo, T.ApmtName, R.RoomID, R.RoomNo, R.RoomName, R.UserNo, R.UserName, M.MeterID, M.ElecAddress " +
  158. leftJoinString + where + ") as mytable " +
  159. " )" +
  160. " AS PageTable " +
  161. " WHERE RowIndex BETWEEN " + start + " AND " + end;
  162. return GetData(watch, pagination, sql);
  163. }
  164. #endregion
  165. #region 获取用户信息 废弃
  166. /// <summary>
  167. /// 获取用户信息
  168. /// </summary>
  169. /// <returns></returns>
  170. private string GetRoomInfo(Pagination pagination, string keyword, string id, string level)
  171. {
  172. string whereSql = GetLevel(level, id);
  173. var watch = CommonHelper.TimerStart();
  174. StringBuilder where = new StringBuilder(whereSql);
  175. StringBuilder sb = new StringBuilder();
  176. string leftJoinString = " from RMRS_AreaInfo A left join RMRS_BldgInfo B on A.AreaID = B.AreaID left join RMRS_ApmtInfo T on B.BldgID = T.BldgID left join RMRS_RoomInfo R on R.ApmtID = T.ApmtID left join RMRS_MeterInfo M on M.RoomID = R.RoomID ";
  177. //if (!"".Equals(keyword))
  178. //{
  179. // sb.Append(" and (R.RoomNo like '%").Append(keyword + "%' or R.RoomName like '%").Append(keyword + "%')");
  180. //}
  181. string sql = " select count(1) " + leftJoinString + where;
  182. pagination.records = Convert.ToInt32(sqlHelper.ExecuteScalar(sql, CommandType.Text, null));
  183. int start = (pagination.page - 1) * pagination.rows + 1;
  184. int end = pagination.page * pagination.rows;
  185. sql = "SELECT PageTable.AreaID, PageTable.AreaName, PageTable.BldgID, PageTable.BldgNo, PageTable.BldgName, PageTable.ApmtID, PageTable.ApmtNo, PageTable.ApmtName, PageTable.RoomID, PageTable.RoomNo, PageTable.RoomName, PageTable.UserNo, PageTable.UserName FROM " +
  186. "( " +
  187. "SELECT " +
  188. " ROW_NUMBER() OVER(ORDER BY RoomID) AS RowIndex," +
  189. " * " +
  190. "FROM " +
  191. " (select A.AreaID, A.AreaName, B.BldgID, B.BldgNo, B.BldgName, T.ApmtID, T.ApmtNo, T.ApmtName, R.RoomID, R.RoomNo, R.RoomName, R.UserNo, R.UserName, M.MeterID, M.ElecAddress " +
  192. leftJoinString + where + ") as mytable " +
  193. " )" +
  194. " AS PageTable " +
  195. " WHERE RowIndex BETWEEN " + start + " AND " + end;
  196. return GetData(watch, pagination, sql);
  197. }
  198. /// <summary>
  199. /// 保存表移动后的位置信息
  200. /// </summary>
  201. /// <param name="meterId">NB表ID</param>
  202. /// <param name="areaId">小区ID</param>
  203. /// <param name="bldgId">楼宇ID</param>
  204. /// <param name="apmtId">单元ID</param>
  205. /// <param name="roomId">房间ID</param>
  206. /// <returns></returns>
  207. public string SaveMeterRemove(string meterId, string areaId, string bldgId, string apmtId, string roomId)
  208. {
  209. AreaInfoEntity areaInfoEntity; //小区信息
  210. BldgInfoEntity bldgInfoEntity; //楼宇信息
  211. ApmtInfoEntity apmtInfoEntity; //单元信息
  212. NBUserEntity nBUserEntity; // 房间信息
  213. NBMeterEntity nBMeterEntity;// NB表信息
  214. string resultMessage = "移表成功"; //返回结果消息
  215. string updateSql; //更新SQL
  216. int sqlResult = 0; //更新SQL 影响的行数
  217. areaInfoEntity = GetAreaInfo(areaId);
  218. bldgInfoEntity = GetBldgInfo(bldgId);
  219. apmtInfoEntity = GetApmtInfo(apmtId);
  220. nBUserEntity = GetUserInfo(roomId);
  221. nBMeterEntity = GetMeterByMeterId(meterId);
  222. // 判断五个ID 在数据库中是否真正的存在
  223. if (areaInfoEntity != null && bldgInfoEntity != null && apmtInfoEntity != null && nBUserEntity != null && nBMeterEntity != null)
  224. {
  225. updateSql = "UPDATE RMRS_MeterInfo SET AreaID=" + areaId + ", BldgID=" + bldgId + ", ApmtID=" + apmtId + ", RoomID=" + roomId + " WHERE MeterID =" + meterId;
  226. sqlResult = sqlHelper.ExecuteNoParams(updateSql, CommandType.Text);
  227. if (sqlResult > 0)
  228. {
  229. resultMessage = "{code:1,message:\"移表操作成功\"}";
  230. }
  231. else
  232. {
  233. resultMessage = "{code:0,message:\"移表操作失败\"}";
  234. }
  235. }
  236. else
  237. {
  238. resultMessage = "{code:0,message:\"参数不合法\"}";
  239. }
  240. return resultMessage;
  241. }
  242. #endregion
  243. #region 获取表具信息
  244. /// <summary>
  245. /// 获取表具信息
  246. /// </summary>
  247. /// <returns></returns>
  248. private string GetMeterInfo(Pagination pagination, string keyword, string id, string level)
  249. {
  250. StringBuilder where = new StringBuilder();
  251. if (!"".Equals(id))
  252. {
  253. string whereSql = GetLevel(level, id);
  254. where.Append(whereSql);
  255. }
  256. Stopwatch watch = CommonHelper.TimerStart();
  257. StringBuilder sb = new StringBuilder();
  258. if (!"".Equals(keyword))
  259. {
  260. if (!"".Equals(id))
  261. {
  262. where.Append(" and ");
  263. }
  264. else
  265. {
  266. where.Append(" where ");
  267. }
  268. where.Append(" (AreaName like '%")
  269. //.Append(keyword + "%' or BldgNo like '%")
  270. .Append(keyword + "%' or BldgName like '%")
  271. .Append(keyword + "%' or ApmtName like '%")
  272. //.Append(keyword + "%' or ApmtNo like '%")
  273. //.Append(keyword + "%' or RoomNo like '%")
  274. .Append(keyword + "%' or RoomName like '%")
  275. .Append(keyword + "%' or UserNo like '%")
  276. .Append(keyword + "%' or ElecAddress like '%")
  277. .Append(keyword + "%' or UserName like '%").Append(keyword + "%')");
  278. }
  279. string sql = " SELECT * FROM dbo.V_WaterMeters " + where;
  280. if (!OperatorProvider.Provider.Current().IsSystem)
  281. {
  282. sql = sql + " AND CompanyId='" + OperatorProvider.Provider.Current().CompanyId + "'";
  283. }
  284. //return GetData(watch, pagination, sql);
  285. int total = pagination.records;
  286. DataTable dt = sqlHelper.ExecuteDataTable(sql, pagination.sidx, pagination.sord, pagination.rows, pagination.page, out total, null);
  287. pagination.records = total;
  288. if (dt.Rows.Count == 0)
  289. {
  290. return GETNoInfo(pagination);
  291. }
  292. //List<NBUserEntity> list = DataHelper.DataTableToT<NBUserEntity>(dt);
  293. var JsonData = new
  294. {
  295. rows = dt,
  296. total = pagination.total,
  297. page = pagination.page,
  298. records = pagination.records,
  299. costtime = CommonHelper.TimerEnd(watch)
  300. };
  301. return JsonData.ToJson();
  302. }
  303. #endregion
  304. #region 获取等级信息
  305. /// <summary>
  306. /// 获取等级信息
  307. /// </summary>
  308. /// <param name="level"></param>
  309. /// <returns></returns>
  310. private string GetLevel(string level, string id)
  311. {
  312. StringBuilder whereSql = new StringBuilder();
  313. switch (level)
  314. {
  315. case "level0":
  316. whereSql.Append("where CompanyId = '").Append(id + " '");
  317. break;
  318. case "level1":
  319. whereSql.Append("where AreaID = ").Append(id);
  320. break;
  321. case "level2":
  322. whereSql.Append("where BldgID = ").Append(id);
  323. break;
  324. case "level3":
  325. whereSql.Append("where ApmtID = ").Append(id);
  326. break;
  327. case "level4":
  328. whereSql.Append("where RoomID = ").Append(id);
  329. break;
  330. case "level5":
  331. whereSql.Append("where MeterID = ").Append(id);
  332. break;
  333. default:
  334. break;
  335. }
  336. return whereSql.ToString();
  337. }
  338. #endregion
  339. #region 获取数据
  340. /// <summary>
  341. /// 获取数据
  342. /// </summary>
  343. /// <param name="sql"></param>
  344. /// <returns></returns>
  345. private string GetData(Stopwatch watch, Pagination pagination, string sql)
  346. {
  347. try
  348. {
  349. DataTable dt = sqlHelper.ExecuteDataTable(sql, CommandType.Text, null);
  350. if (dt.Rows.Count == 0)
  351. {
  352. return GETNoInfo(pagination);
  353. }
  354. //List<NBUserEntity> list = DataHelper.DataTableToT<NBUserEntity>(dt);
  355. var JsonData = new
  356. {
  357. rows = dt,
  358. total = pagination.total,
  359. page = pagination.page,
  360. records = pagination.records,
  361. costtime = CommonHelper.TimerEnd(watch)
  362. };
  363. return JsonData.ToJson();
  364. }
  365. catch (Exception e)
  366. {
  367. throw e;
  368. }
  369. }
  370. #endregion
  371. #region 保存区域数据
  372. /// <summary>
  373. /// 保存区域数据
  374. /// </summary>
  375. /// <param name="data"></param>
  376. /// <returns>0:失败,2:重复,1:成功</returns>
  377. public int SaveAreaForm(string data)
  378. {
  379. try
  380. {
  381. AreaInfoEntity entity = data.ToObject<AreaInfoEntity>();
  382. StringBuilder searchSql = new StringBuilder(" select count(1) from RMRS_AreaInfo where AreaName = ").Append("'" + entity.AreaName + "'");
  383. if (Convert.ToInt32(sqlHelper.ExecuteScalar(searchSql.ToString(), CommandType.Text, null)) > 0)
  384. {
  385. return 2;
  386. }
  387. StringBuilder sb = new StringBuilder(" insert into RMRS_AreaInfo ( AreaName, AreaLoc, AreaMemo ,CompanyId ) values ( ")
  388. .Append("'" + entity.AreaName + "', ")
  389. .Append("'" + entity.AreaLoc + "', ")
  390. .Append("'" + entity.AreaMemo + "',")
  391. .Append("'" + OperatorProvider.Provider.Current().CompanyId + "')");
  392. return sqlHelper.ExecuteNoParams(sb.ToString(), CommandType.Text) > 0 ? 1 : 0;
  393. }
  394. catch (Exception)
  395. {
  396. throw;
  397. }
  398. }
  399. #endregion
  400. #region 获取区域信息
  401. /// <summary>
  402. /// 获取区域信息
  403. /// </summary>
  404. /// <returns></returns>
  405. public AreaInfoEntity GetAreaInfo(string id)
  406. {
  407. StringBuilder sb = new StringBuilder(" select AreaName, AreaLoc, AreaMemo from RMRS_AreaInfo where AreaID = ").Append(id);
  408. try
  409. {
  410. DataTable dt = sqlHelper.ExecuteDataTable(sb.ToString(), CommandType.Text, null);
  411. if (dt.Rows.Count > 0)
  412. {
  413. AreaInfoEntity entity = new AreaInfoEntity();
  414. entity.AreaName = dt.Rows[0]["AreaName"].ToString();
  415. entity.AreaLoc = dt.Rows[0]["AreaLoc"].ToString();
  416. entity.AreaMemo = dt.Rows[0]["AreaMemo"].ToString();
  417. return entity;
  418. }
  419. else
  420. {
  421. return null;
  422. }
  423. }
  424. catch (Exception)
  425. {
  426. return null;
  427. }
  428. }
  429. #endregion
  430. #region 修改小区信息
  431. /// <summary>
  432. /// 修改小区信息
  433. /// </summary>
  434. /// <param name="data"></param>
  435. /// <returns></returns>
  436. public int EditAreaForm(string id, string data)
  437. {
  438. try
  439. {
  440. AreaInfoEntity entity = data.ToObject<AreaInfoEntity>();
  441. StringBuilder sb = new StringBuilder(" update RMRS_AreaInfo set AreaName = ")
  442. .Append("'" + entity.AreaName + "', AreaLoc = ")
  443. .Append("'" + entity.AreaLoc + "', AreaMemo = ")
  444. .Append("'" + entity.AreaMemo + "'")
  445. .Append(" where AreaID = ").Append(id)
  446. ;
  447. return sqlHelper.ExecuteNoParams(sb.ToString(), CommandType.Text) > 0 ? 1 : 0;
  448. }
  449. catch (Exception)
  450. {
  451. throw;
  452. }
  453. }
  454. #endregion
  455. #region 删除区域信息
  456. /// <summary>
  457. /// 删除区域信息
  458. /// </summary>
  459. /// <param name="id"></param>
  460. /// <returns></returns>
  461. public int DeleteAreaForm(string id)
  462. {
  463. //删除前判断 有无楼宇信息
  464. string selSql = "select * from RMRS_BldgInfo where AreaID = " + id;
  465. DataTable dtResult = sqlHelper.ExecuteDataTable(selSql, CommandType.Text, null);
  466. if (dtResult.Rows.Count > 0)
  467. {
  468. return 2;
  469. }
  470. StringBuilder sb = new StringBuilder("delete from RMRS_AreaInfo where AreaID = ").Append(id);
  471. try
  472. {
  473. return sqlHelper.ExecuteNoParams(sb.ToString(), CommandType.Text) > 0 ? 1 : 0;
  474. }
  475. catch (Exception)
  476. {
  477. throw;
  478. }
  479. }
  480. #endregion
  481. #region 保存楼宇信息
  482. /// <summary>
  483. /// 保存楼宇信息
  484. /// </summary>
  485. /// <param name="data"></param>
  486. /// <returns></returns>
  487. public int SaveBldgForm(string parentId, string data)
  488. {
  489. try
  490. {
  491. BldgInfoEntity entity = data.ToObject<BldgInfoEntity>();
  492. StringBuilder sb = new StringBuilder(" insert into RMRS_BldgInfo ( AreaID, BldgName ) values ( ")
  493. .Append(parentId + ", ")
  494. .Append("'" + entity.BldgName + "' )");
  495. return sqlHelper.ExecuteNoParams(sb.ToString(), CommandType.Text) > 0 ? 1 : 0;
  496. }
  497. catch (Exception)
  498. {
  499. throw;
  500. }
  501. }
  502. /// <summary>
  503. /// 批量保存楼宇信息
  504. /// </summary>
  505. /// <param name="data"></param>
  506. /// <returns></returns>
  507. public int SaveBatchBldgForm(string parentId, string data)
  508. {
  509. try
  510. {
  511. JObject jObj = Json.ToJObject(data);
  512. int benginBldbNo = Convert.ToInt32(jObj["BldgBeginNo"].ToString());
  513. int bldgNum = Convert.ToInt32(jObj["BldgNum"].ToString());
  514. string bldgExtName = jObj["BldgExtName"].ToString();
  515. for (int i = 0; i < bldgNum; i++)
  516. {
  517. BldgInfoEntity entity = new BldgInfoEntity();
  518. entity.BldgName = (benginBldbNo + i) + bldgExtName;
  519. StringBuilder sb = new StringBuilder(" insert into RMRS_BldgInfo ( AreaID, BldgName, BldgNo ) values ( ")
  520. .Append(parentId + ", ")
  521. .Append("'" + entity.BldgName + "' ) ");
  522. sqlHelper.ExecuteNoParams(sb.ToString(), CommandType.Text);
  523. }
  524. return 1;
  525. }
  526. catch (Exception)
  527. {
  528. throw;
  529. }
  530. }
  531. #endregion
  532. #region 获取楼宇信息
  533. /// <summary>
  534. /// 获取楼宇信息
  535. /// </summary>
  536. /// <param name="id"></param>
  537. /// <returns></returns>
  538. public BldgInfoEntity GetBldgInfo(string id)
  539. {
  540. StringBuilder sb = new StringBuilder(" select BldgName, BldgNo ,AreaID from RMRS_BldgInfo where BldgID = ").Append(id);
  541. try
  542. {
  543. DataTable dt = sqlHelper.ExecuteDataTable(sb.ToString(), CommandType.Text, null);
  544. if (dt.Rows.Count > 0)
  545. {
  546. BldgInfoEntity entity = new BldgInfoEntity();
  547. entity.BldgName = dt.Rows[0]["BldgName"].ToString();
  548. entity.BldgNo = dt.Rows[0]["BldgNo"].ToString();
  549. entity.AreaID = dt.Rows[0]["AreaID"].ToString();
  550. return entity;
  551. }
  552. else
  553. {
  554. return null;
  555. }
  556. }
  557. catch (Exception)
  558. {
  559. return null;
  560. }
  561. }
  562. #endregion
  563. #region 修改楼宇信息
  564. /// <summary>
  565. /// 修改楼宇信息
  566. /// </summary>
  567. /// <param name="id"></param>
  568. /// <param name="data"></param>
  569. /// <returns></returns>
  570. public int EditBldgForm(string parentId, string id, string data)
  571. {
  572. try
  573. {
  574. BldgInfoEntity entity = data.ToObject<BldgInfoEntity>();
  575. StringBuilder sb = new StringBuilder(" update RMRS_BldgInfo set BldgName = ")
  576. .Append("'" + entity.BldgName + "' ")
  577. .Append(" where BldgID = ").Append(id);
  578. return sqlHelper.ExecuteNoParams(sb.ToString(), CommandType.Text) > 0 ? 1 : 0;
  579. }
  580. catch (Exception)
  581. {
  582. throw;
  583. }
  584. }
  585. #endregion
  586. #region 删除楼宇信息
  587. /// <summary>
  588. /// 删除楼宇信息
  589. /// </summary>
  590. /// <param name="id"></param>
  591. /// <returns></returns>
  592. public int DeleteBldgForm(string id)
  593. {
  594. //删除前判断 有无单元信息
  595. string selSql = "select * from RMRS_ApmtInfo where BldgID = " + id;
  596. DataTable dtResult = sqlHelper.ExecuteDataTable(selSql, CommandType.Text, null);
  597. if (dtResult.Rows.Count > 0)
  598. {
  599. return 2;
  600. }
  601. StringBuilder sb = new StringBuilder("delete from RMRS_BldgInfo where BldgID = ").Append(id);
  602. try
  603. {
  604. return sqlHelper.ExecuteNoParams(sb.ToString(), CommandType.Text) > 0 ? 1 : 0;
  605. }
  606. catch (Exception)
  607. {
  608. throw;
  609. }
  610. }
  611. #endregion
  612. #region 保存单元信息
  613. /// <summary>
  614. /// 保存单元信息
  615. /// </summary>
  616. /// <param name="data"></param>
  617. /// <returns></returns>
  618. public int SaveApmtForm(string parentId, string data)
  619. {
  620. try
  621. {
  622. ApmtInfoEntity entity = data.ToObject<ApmtInfoEntity>();
  623. StringBuilder sb = new StringBuilder(" insert into RMRS_ApmtInfo ( BldgID, ApmtName ) values ( ")
  624. .Append(parentId + ", ")
  625. .Append("'" + entity.ApmtName + "') ");
  626. return sqlHelper.ExecuteNoParams(sb.ToString(), CommandType.Text) > 0 ? 1 : 0;
  627. }
  628. catch (Exception)
  629. {
  630. throw;
  631. }
  632. }
  633. /// <summary>
  634. /// 批量保存楼宇信息
  635. /// </summary>
  636. /// <param name="data"></param>
  637. /// <returns></returns>
  638. public int SaveBatchApmtForm(string parentId, string data)
  639. {
  640. try
  641. {
  642. JObject jObj = Json.ToJObject(data);
  643. int benginApmtNo = Convert.ToInt32(jObj["ApmtBeginNo"].ToString());
  644. int apmtNum = Convert.ToInt32(jObj["ApmtNum"].ToString());
  645. string apmtExtName = jObj["ApmtExtName"].ToString();
  646. for (int i = 0; i < apmtNum; i++)
  647. {
  648. ApmtInfoEntity entity = new ApmtInfoEntity();
  649. entity.ApmtName = (benginApmtNo + i) + apmtExtName;
  650. entity.ApmtNo = (benginApmtNo + i).ToString();
  651. StringBuilder sb = new StringBuilder(" insert into RMRS_ApmtInfo ( BldgID, ApmtName) values ( ")
  652. .Append(parentId + ", ")
  653. .Append("'" + entity.ApmtName + "')");
  654. sqlHelper.ExecuteNoParams(sb.ToString(), CommandType.Text);
  655. }
  656. return 1;
  657. }
  658. catch (Exception)
  659. {
  660. throw;
  661. }
  662. }
  663. #endregion
  664. #region 获取单元信息
  665. /// <summary>
  666. /// 获取单元信息
  667. /// </summary>
  668. /// <param name="id"></param>
  669. /// <returns></returns>
  670. public ApmtInfoEntity GetApmtInfo(string id)
  671. {
  672. StringBuilder sb = new StringBuilder(" select ApmtName, ApmtNo,BldgID from RMRS_ApmtInfo where ApmtID = ").Append(id);
  673. try
  674. {
  675. DataTable dt = sqlHelper.ExecuteDataTable(sb.ToString(), CommandType.Text, null);
  676. if (dt.Rows.Count > 0)
  677. {
  678. ApmtInfoEntity entity = new ApmtInfoEntity();
  679. entity.ApmtName = dt.Rows[0]["ApmtName"].ToString();
  680. entity.ApmtNo = dt.Rows[0]["ApmtNo"].ToString();
  681. entity.BldgID = dt.Rows[0]["BldgID"].ToString();
  682. return entity;
  683. }
  684. else
  685. {
  686. return null;
  687. }
  688. }
  689. catch (Exception)
  690. {
  691. return null;
  692. }
  693. }
  694. #endregion
  695. #region 修改单元信息
  696. /// <summary>
  697. /// 修改单元信息
  698. /// </summary>
  699. /// <param name="id"></param>
  700. /// <param name="data"></param>
  701. /// <returns></returns>
  702. public int EditApmtForm(string parentId, string id, string data)
  703. {
  704. try
  705. {
  706. ApmtInfoEntity entity = data.ToObject<ApmtInfoEntity>();
  707. StringBuilder sb = new StringBuilder(" update RMRS_ApmtInfo set ApmtName = ")
  708. .Append("'" + entity.ApmtName + "'")
  709. .Append(" where ApmtID = ").Append(id);
  710. return sqlHelper.ExecuteNoParams(sb.ToString(), CommandType.Text) > 0 ? 1 : 0;
  711. }
  712. catch (Exception)
  713. {
  714. throw;
  715. }
  716. }
  717. #endregion
  718. #region 删除单元信息
  719. /// <summary>
  720. /// 删除单元信息
  721. /// </summary>
  722. /// <param name="id"></param>
  723. /// <returns></returns>
  724. public int DeleteApmtForm(string id)
  725. {
  726. //删除前判断 有无用户数据
  727. string selSql = "select * from RMRS_RoomInfo where ApmtID = " + id;
  728. DataTable dtResult = sqlHelper.ExecuteDataTable(selSql, CommandType.Text, null);
  729. if (dtResult.Rows.Count > 0)
  730. {
  731. return 2;
  732. }
  733. StringBuilder sb = new StringBuilder("delete from RMRS_ApmtInfo where ApmtID = ").Append(id);
  734. try
  735. {
  736. return sqlHelper.ExecuteNoParams(sb.ToString(), CommandType.Text) > 0 ? 1 : 0;
  737. }
  738. catch (Exception)
  739. {
  740. throw;
  741. }
  742. }
  743. #endregion
  744. #region 保存用户信息
  745. /// <summary>
  746. /// 保存用户信息
  747. /// </summary>
  748. /// <param name="data"></param>
  749. /// <returns></returns>
  750. public int SaveUserForm(string parentId, string data)
  751. {
  752. try
  753. {
  754. NBUserEntity entity = data.ToObject<NBUserEntity>();
  755. entity.ApmtID = parentId;
  756. string insertSql = DataHelper.ModelToInsertSql<NBUserEntity>(entity, "RMRS_RoomInfo");
  757. return Convert.ToInt32(sqlHelper.ExecuteScalar(insertSql + " SELECT @@IDENTITY", CommandType.Text).ToString());
  758. }
  759. catch (Exception)
  760. {
  761. throw;
  762. }
  763. }
  764. /// <summary>
  765. /// 批量保存用户信息
  766. /// </summary>
  767. /// <param name="data"></param>
  768. /// <returns></returns>
  769. public int SaveBatchUserForm(string parentId, string data)
  770. {
  771. try
  772. {
  773. JObject jObj = Json.ToJObject(data);
  774. int roomBeginNo = Convert.ToInt32(jObj["RoomBeginNo"].ToString());
  775. int roomNum = Convert.ToInt32(jObj["RoomNum"].ToString());
  776. string roomExtName = jObj["RoomExtName"].ToString();
  777. for (int i = 0; i < roomNum; i++)
  778. {
  779. //修改为同一楼宇 单元名字不能重复
  780. StringBuilder searchSql = new StringBuilder(" select count(1) from RMRS_RoomInfo where RoomNo = ").Append("'" + (roomBeginNo + i).ToString() + "' And ApmtID = " + parentId);
  781. if (Convert.ToInt32(sqlHelper.ExecuteScalar(searchSql.ToString(), CommandType.Text, null)) > 0)
  782. {
  783. continue;
  784. }
  785. StringBuilder sb = new StringBuilder(" insert into RMRS_RoomInfo ( ApmtID, RoomNo, RoomName ) values ( ")
  786. .Append(parentId + ", ")
  787. .Append("'" + (roomBeginNo + i) + roomExtName + "', ")
  788. .Append("'" + (roomBeginNo + i).ToString() + "')");
  789. sqlHelper.ExecuteNoParams(sb.ToString(), CommandType.Text);
  790. }
  791. return 1;
  792. }
  793. catch (Exception)
  794. {
  795. throw;
  796. }
  797. }
  798. #endregion
  799. #region 获取用户信息
  800. /// <summary>
  801. /// 获取单元信息
  802. /// </summary>
  803. /// <param name="id"></param>
  804. /// <returns></returns>
  805. public NBUserEntity GetUserInfo(string id)
  806. {
  807. StringBuilder sb = new StringBuilder(" select * from RMRS_RoomInfo where RoomID = ").Append(id);
  808. try
  809. {
  810. DataTable dt = sqlHelper.ExecuteDataTable(sb.ToString(), CommandType.Text, null);
  811. if (dt.Rows.Count > 0)
  812. {
  813. return DataHelper.DataTableToT<NBUserEntity>(dt)[0];
  814. }
  815. else
  816. {
  817. return null;
  818. }
  819. }
  820. catch (Exception)
  821. {
  822. return null;
  823. }
  824. }
  825. #endregion
  826. #region 修改用户信息
  827. /// <summary>
  828. /// 修改单元信息
  829. /// </summary>
  830. /// <param name="id"></param>
  831. /// <param name="data"></param>
  832. /// <returns></returns>
  833. public int EditUserForm(string parentId, string id, string data)
  834. {
  835. try
  836. {
  837. NBUserEntity entity = data.ToObject<NBUserEntity>();
  838. string updateSql = DataHelper.ModelToUpdateSql<NBUserEntity>(entity, "RMRS_RoomInfo");
  839. return sqlHelper.ExecuteNoParams(updateSql.ToString(), CommandType.Text) > 0 ? 1 : 0;
  840. }
  841. catch (Exception)
  842. {
  843. throw;
  844. }
  845. }
  846. #endregion
  847. #region 删除用户信息
  848. /// <summary>
  849. /// 删除用户信息
  850. /// </summary>
  851. /// <param name="id"></param>
  852. /// <returns></returns>
  853. public int DeleteUserForm(string id)
  854. {
  855. try
  856. {
  857. //删除用户的时候 同步删除表
  858. string selUserMeter = "SELECT * FROM RMRS_MeterInfo WHERE RoomID = " + id;
  859. DataTable dtMeter = sqlHelper.ExecuteDataTable(selUserMeter, CommandType.Text, null);
  860. string meterId = "";
  861. for (int row = 0; row < dtMeter.Rows.Count; row++)
  862. {
  863. meterId = dtMeter.Rows[row]["MeterID"].ToString();
  864. DeleteMeterForm(meterId);
  865. }
  866. StringBuilder sb = new StringBuilder("delete from RMRS_RoomInfo where RoomID = ").Append(id);
  867. return sqlHelper.ExecuteNoParams(sb.ToString(), CommandType.Text) > 0 ? 1 : 0;
  868. }
  869. catch (Exception)
  870. {
  871. throw;
  872. }
  873. }
  874. #endregion
  875. #region 添加用户时,先添加用户,再获得用户ID
  876. /// <summary>
  877. ///获得用户ID
  878. /// </summary>
  879. /// <param name="RoomNo">用户</param>
  880. /// <param name="ApmtID">单元ID</param>
  881. /// <param name="BldgID">楼宇ID</param>
  882. /// <param name="AreaID">小区ID</param>
  883. /// <returns></returns>
  884. public string GetRoomID(string RoomNo, string ApmtID, string BldgID, string AreaID)
  885. {
  886. string sql = @"select room.* from RMRS_RoomInfo room
  887. left join RMRS_ApmtInfo apmt on room.ApmtID=apmt.ApmtID
  888. left join RMRS_BldgInfo bldg on apmt.BldgID=bldg.BldgID
  889. left join RMRS_AreaInfo area on bldg.AreaID=area.AreaID
  890. where room.RoomNo='" + RoomNo + @"'
  891. and apmt.ApmtID=" + ApmtID + @"
  892. and bldg.BldgID=" + BldgID + @"
  893. and area.AreaID=" + AreaID;
  894. DataTable dt = sqlHelper.ExecuteDataTable(sql, CommandType.Text, null);
  895. string roomid = dt.Rows[0]["RoomID"].ToString();
  896. return roomid;
  897. }
  898. #endregion
  899. #region 保存表具信息
  900. /// <summary>
  901. /// 保存用户信息
  902. /// </summary>
  903. /// <param name="data"></param>
  904. /// <returns></returns>
  905. public int SaveMeterForm(string parentId, string data)
  906. {
  907. try
  908. {
  909. NBMeterEntity entity = data.ToObject<NBMeterEntity>();
  910. entity.RoomID = Convert.ToInt32(parentId);
  911. NBUserEntity userEntity = GetUserInfo(parentId.ToString());
  912. entity.ApmtID = Convert.ToInt32(userEntity.ApmtID);
  913. ApmtInfoEntity apmtInfoEntity = GetApmtInfo(userEntity.ApmtID);
  914. entity.BldgID = Convert.ToInt32(apmtInfoEntity.BldgID);
  915. BldgInfoEntity bldgInfoEntity = GetBldgInfo(apmtInfoEntity.BldgID);
  916. entity.AreaID = Convert.ToInt32(bldgInfoEntity.AreaID);
  917. string insertSql = DataHelper.ModelToInsertSql<NBMeterEntity>(entity, "RMRS_MeterInfo");
  918. object meterId = sqlHelper.ExecuteScalar(insertSql + " SELECT @@identity ", CommandType.Text, null);//获取新插入数据的ID
  919. //华为平台注册
  920. JObject jObj = NBCommon.RegisterMeter(entity.IMEI, "0");
  921. //注册成功
  922. if (jObj["deviceId"] != null)
  923. {
  924. string deviceId = jObj["deviceId"].ToString();
  925. //同步数据库
  926. string updateSql = "UPDATE RMRS_MeterInfo SET IOT_Code = '" + deviceId + "', SyncMark = 1 where MeterID = " + meterId.ToString();
  927. sqlHelper.ExecuteNoParams(updateSql, CommandType.Text);
  928. string selSql = "SELECT * FROM dbo.V_WaterMeters WHERE IOT_Code='" + deviceId + "'";
  929. DataTable dtMeter = sqlHelper.ExecuteDataTable(selSql, CommandType.Text, null);
  930. string protocolType = dtMeter.Rows[0]["MeterTypeName"].ToString();//协议类型
  931. string deviceType = dtMeter.Rows[0]["NBDevTypeName"].ToString();
  932. string manufacturerId = dtMeter.Rows[0]["NBDevManufacturerName"].ToString();
  933. string manufacturerName = dtMeter.Rows[0]["NBDevManufacturerCodeName"].ToString();
  934. string model = dtMeter.Rows[0]["NBTypeCodeName"].ToString();
  935. //平台基础信息修改 Device Type,Manufacturer ID,Manufacturer Name,Model,Protocol Type,region,organization,timezone
  936. //TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  937. //string totalSeconds = ts.TotalSeconds.ToString().Split('.')[0];
  938. NBCommon.UpdateMeterParams(deviceId, entity.ElecAddress, deviceType, manufacturerId, manufacturerName, model, protocolType, "WWKJ_" + entity.ElecAddress);
  939. return 0;
  940. }
  941. //平台设备已经存在
  942. else if (jObj["error_code"] != null && jObj["error_code"].ToString() == "200")
  943. {
  944. //查找 IMEI 在本地存储的IOT_CODE 有的话 执行删除操作
  945. return 2;
  946. }
  947. //获取失败
  948. if (jObj["error_code"] != null)
  949. {
  950. log.Error(jObj.ToString() + " time:" + DateTime.Now);
  951. }
  952. return 0;
  953. }
  954. catch (Exception ex)
  955. {
  956. log.Error(ex.Message + " time:" + DateTime.Now);
  957. return 1;
  958. }
  959. }
  960. #endregion
  961. #region 编辑表具信息
  962. /// <summary>
  963. /// 保存用户信息
  964. /// </summary>
  965. /// <param name="data"></param>
  966. /// <returns></returns>
  967. public int EditMeterForm(string meterId, string data)
  968. {
  969. try
  970. {
  971. NBMeterEntity oldEntity = GetMeterByMeterId(meterId);
  972. NBMeterEntity entity = data.ToObject<NBMeterEntity>();
  973. entity.RoomID = oldEntity.RoomID;
  974. entity.ApmtID = oldEntity.ApmtID;
  975. entity.BldgID = oldEntity.BldgID;
  976. entity.AreaID = oldEntity.AreaID;
  977. entity.MeterID = int.Parse(meterId);
  978. string updateSql = DataHelper.ModelToUpdateSql<NBMeterEntity>(entity, "RMRS_MeterInfo");
  979. sqlHelper.ExecuteNonQuery(updateSql, CommandType.Text, null);
  980. string deviceId = oldEntity.IOT_Code;
  981. //同步数据库
  982. string selSql = "SELECT * FROM dbo.V_WaterMeters WHERE IOT_Code='" + deviceId + "'";
  983. DataTable dtMeter = sqlHelper.ExecuteDataTable(selSql, CommandType.Text, null);
  984. string protocolType = dtMeter.Rows[0]["MeterTypeName"].ToString();//协议类型
  985. string deviceType = dtMeter.Rows[0]["NBDevTypeName"].ToString();
  986. string manufacturerId = dtMeter.Rows[0]["NBDevManufacturerName"].ToString();
  987. string manufacturerName = dtMeter.Rows[0]["NBDevManufacturerCodeName"].ToString();
  988. string model = dtMeter.Rows[0]["NBTypeCodeName"].ToString();
  989. //平台基础信息修改 Device Type,Manufacturer ID,Manufacturer Name,Model,Protocol Type,region,organization,timezone
  990. TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  991. string totalSeconds = ts.TotalSeconds.ToString().Split('.')[0];
  992. NBCommon.UpdateMeterParams(deviceId, entity.ElecAddress, deviceType, manufacturerId, manufacturerName, model, protocolType, "WWKJ_" + entity.ElecAddress);
  993. return 0;
  994. }
  995. catch (Exception ex)
  996. {
  997. log.Error(ex.Message + " time:" + DateTime.Now);
  998. return 1;
  999. }
  1000. }
  1001. #endregion
  1002. #region 获取表具信息
  1003. /// <summary>
  1004. /// 保存用户信息
  1005. /// </summary>
  1006. /// <param name="data"></param>
  1007. /// <returns></returns>
  1008. public NBMeterEntity GetMeterByMeterId(string meterId)
  1009. {
  1010. try
  1011. {
  1012. string selSql = "SELECT * FROM RMRS_MeterInfo WHERE MeterID = " + meterId;
  1013. DataTable dtResult = sqlHelper.ExecuteDataTable(selSql, CommandType.Text, null);
  1014. List<NBMeterEntity> lists = DataHelper.DataTableToT<NBMeterEntity>(dtResult);
  1015. if (lists != null)
  1016. {
  1017. return lists[0];
  1018. }
  1019. return null;
  1020. }
  1021. catch (Exception ex)
  1022. {
  1023. return null;
  1024. }
  1025. }
  1026. #endregion
  1027. #region 删除表具信息
  1028. /// <summary>
  1029. /// 删除表具信息
  1030. /// </summary>
  1031. /// <param name="data"></param>
  1032. /// <returns></returns>
  1033. public int DeleteMeterForm(string meterId)
  1034. {
  1035. try
  1036. {
  1037. NBMeterEntity entity = GetMeterByMeterId(meterId);
  1038. string iot_code = entity.IOT_Code;
  1039. //string delSql = "DELETE FROM RMRS_MeterInfo WHERE MeterID=" + meterId;
  1040. string delSql = "UPDATE RMRS_MeterInfo SET DeleteMark=1 WHERE MeterID=" + meterId;
  1041. sqlHelper.ExecuteNoParams(delSql, CommandType.Text);
  1042. //表具删除 同步的历史数据删除
  1043. //string delHisSql = "DELETE FROM RMRS_HistoryRecord WHERE MeterID=" + meterId;
  1044. //sqlHelper.ExecuteNoParams(delHisSql, CommandType.Text);
  1045. //同步表 弃用 改为 回调模式
  1046. //string delHisTaskSql = "DELETE FROM RMRS_HistoryTask WHERE IOT_Code='" + iot_code + "'";
  1047. //sqlHelper.ExecuteNoParams(delHisTaskSql, CommandType.Text);
  1048. NBCommon.DeleteMeter(iot_code);
  1049. return 1;
  1050. }
  1051. catch (Exception ex)
  1052. {
  1053. return 0;
  1054. }
  1055. }
  1056. #endregion
  1057. }
  1058. }