JLH_FetchPriceExcutor.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.erp_mtrlid > 0
  35. and u_mattress_interface_qd.actual_useqty > 0
  36. and u_mattress_interface_qd.mtrlid > 0
  37. GROUP BY u_mattress_interface_qd.mtrlid, u_mattress_interface_qd.erp_mtrlid
  38. ";
  39. cmd.Parameters.Clear();
  40. using (var reader = cmd.ExecuteReader())
  41. {
  42. while (reader.Read())
  43. {
  44. rslt.list.Add(new u_configure_codemx()
  45. {
  46. mtrlcode = Convert.ToString(reader["mtrlcode"]).Trim(),
  47. price = Convert.ToDecimal(reader["price"]),
  48. });
  49. }
  50. }
  51. }
  52. }
  53. }
  54. }