JLH_FetchPriceExcutor.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using JLHHJSvr.Com;
  5. using JLHHJSvr.Com.Model;
  6. using LJLib.Net.SPI.Server;
  7. namespace JLHHJSvr.Excutor
  8. {
  9. internal sealed class JLH_FetchPriceExcutor:ExcutorBase<JLH_FetchPriceRequest, JLH_FetchPriceResponse>
  10. {
  11. protected override void ExcuteInternal(JLH_FetchPriceRequest request, object state, JLH_FetchPriceResponse rslt)
  12. {
  13. if (request.token != "7DEA6FF3-3E81-4EDA-8A02-1F56073A45FD")
  14. {
  15. rslt.ErrMsg = "会话已经中断,请重新登录";
  16. return;
  17. }
  18. using (var con = new SqlConnection(GlobalVar.ConnectionString))
  19. using (var cmd = con.CreateCommand())
  20. {
  21. con.Open();
  22. rslt.list = new List<u_configure_codemx>();
  23. cmd.CommandText = @"SELECT
  24. MAX(
  25. CASE WHEN u_mattress_interface_qd.erp_mtrlid > 0 and u_mattress_interface_qd.actual_useqty > 0
  26. THEN u_mattress_mx_mtrl.costamt / u_mattress_interface_qd.actual_useqty
  27. ELSE 0 END
  28. ) AS price
  29. ,u_mattress_interface_qd.mtrlid, u_mattress_interface_qd.erp_mtrlid
  30. from u_mattress_interface_qd
  31. inner join u_mattress_mx_mtrl on u_mattress_mx_mtrl.mattressid = u_mattress_interface_qd.mattressid
  32. and u_mattress_mx_mtrl.mtrlid = u_mattress_interface_qd.mtrlid
  33. where
  34. u_mattress_interface_qd.mattressid = 17493977
  35. and
  36. u_mattress_interface_qd.erp_mtrlid > 0
  37. and u_mattress_interface_qd.actual_useqty > 0
  38. and u_mattress_interface_qd.mtrlid > 0
  39. GROUP BY u_mattress_interface_qd.mtrlid, u_mattress_interface_qd.erp_mtrlid
  40. ";
  41. cmd.Parameters.Clear();
  42. using (var reader = cmd.ExecuteReader())
  43. {
  44. while (reader.Read())
  45. {
  46. rslt.list.Add(new u_configure_codemx()
  47. {
  48. mtrlcode = Convert.ToString(reader["mtrlcode"]).Trim(),
  49. price = Convert.ToDecimal(reader["price"]),
  50. });
  51. }
  52. }
  53. }
  54. }
  55. }
  56. }