BasicInfoHelper.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. using DirectService.Tools;
  2. using JLHHJSvr.BLL;
  3. using JLHHJSvr.Com.Model;
  4. using JLHHJSvr.LJException;
  5. using LJLib.DAL.SQL;
  6. using NPOI.SS.Formula;
  7. using NPOI.SS.Formula.Functions;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Web.UI.WebControls.WebParts;
  14. namespace JLHHJSvr.Helper
  15. {
  16. internal class BasicInfoHelper: HelperBase
  17. {
  18. /// <summary>
  19. /// 核价选配类型-保存
  20. /// </summary>
  21. /// <param name="configure"></param>
  22. public void SaveConfigureType(u_configure_type configure)
  23. {
  24. if (configure.contfigtypeid <= 0)
  25. {
  26. configure.contfigtypeid = BllHelper.GetID(cmd, "u_configure_type");
  27. var fields = @"contfigtypeid,contfigtype,contfigtypename,usechflag,flag";
  28. DbSqlHelper.Insert(cmd, "u_configure_type", null, configure, fields);
  29. }
  30. else
  31. {
  32. configure.moddate = context.opdate;
  33. configure.modemp = context.tokendata.username;
  34. //修改
  35. var fields = @"contfigtype,contfigtypename,usechflag,modemp,moddate";
  36. DbSqlHelper.Update(cmd, "u_configure_type", null, configure, "contfigtypeid", fields);
  37. }
  38. }
  39. /// <summary>
  40. /// 核价选配项值-保存
  41. /// </summary>
  42. /// <param name="configure"></param>
  43. public void SaveConfigureCodeMx(u_configure_codemx codeMx)
  44. {
  45. if (codeMx.printid <= 0)
  46. {
  47. int _printid = 0;
  48. cmd.CommandText = @"SELECT ISNULL(MAX(printid),0) AS printid FROM u_configure_codemx WHERE pzid = @pzid";
  49. cmd.Parameters.Clear();
  50. cmd.Parameters.AddWithValue("@pzid", codeMx.pzid);
  51. using (var reader = cmd.ExecuteReader())
  52. {
  53. if (reader.Read())
  54. {
  55. _printid = Convert.ToInt32(reader["printid"]);
  56. }
  57. }
  58. codeMx.printid = _printid + 1;
  59. var fields = @"pzid,printid,pzcodemx,namemx,gradestr,mtrlcode,price,ifdft,MCostRate,ProfitRate,dscrp,ifuse,ifnoch,pricerate,packqty,packvol,price_pz,grade";
  60. DbSqlHelper.Insert(cmd, "u_configure_codemx", null, codeMx, fields);
  61. }
  62. else
  63. {
  64. //修改
  65. var fields = @"pzcodemx,namemx,gradestr,mtrlcode,price,ifdft,MCostRate,ProfitRate,dscrp,ifuse,ifnoch,pricerate,packqty,packvol,price_pz,grade";
  66. DbSqlHelper.Update(cmd, "u_configure_codemx", null, codeMx, "pzid,printid", fields);
  67. }
  68. }
  69. /// <summary>
  70. /// 核价软床公式定义-保存
  71. /// </summary>
  72. /// <param name="formula"></param>
  73. public void SaveSoftBedFormula(u_softbed_formula formula)
  74. {
  75. if (formula == null)
  76. {
  77. throw new LJCommonException("未提交软床公式定义信息");
  78. }
  79. if (string.IsNullOrEmpty(formula.formulaname))
  80. {
  81. throw new LJCommonException($"公式名称不能为空,请检查!");
  82. }
  83. var fields = "formulaname,price_formula,use_formula";
  84. if (formula.formulaid <= 0)
  85. {
  86. // 新建
  87. fields += ",formulaid,create_date,create_emp";
  88. formula.formulaid = BllHelper.GetID(cmd, "u_softbed_formula");
  89. formula.create_date = context.opdate;
  90. formula.create_emp = context.tokendata.username;
  91. DbSqlHelper.Insert(cmd, "u_softbed_formula", null, formula, fields);
  92. }
  93. else
  94. {
  95. //修改
  96. fields += ",update_date,update_emp";
  97. formula.update_date = context.opdate;
  98. formula.update_emp = context.tokendata.username;
  99. DbSqlHelper.Update(cmd, "u_softbed_formula", null, formula, "formulaid", fields);
  100. }
  101. }
  102. /// <summary>
  103. /// 保存ERP物料资料定义
  104. /// </summary>
  105. /// <param name="mtrl"></param>
  106. /// <exception cref="LJCommonException"></exception>
  107. public void SaveErpMtrlPrice(u_erpmtrl_price mtrl)
  108. {
  109. var fields = "";
  110. if(mtrl.mtrlid <= 0)
  111. {
  112. throw new LJCommonException("物料ID有误,请检查!");
  113. }
  114. mtrl.update_date = context.opdate;
  115. mtrl.update_emp = context.tokendata.username;
  116. if(DbSqlHelper.Update(cmd, "u_erpmtrl_price", null, mtrl, "mtrlid", "price,update_date,update_emp") == 0)
  117. {
  118. mtrl.create_date = context.opdate;
  119. mtrl.create_emp = context.tokendata.username;
  120. DbSqlHelper.Insert(cmd, "u_erpmtrl_price", null, mtrl, "mtrlid,price,create_date,create_emp");
  121. }
  122. }
  123. /// <summary>
  124. /// 获取ERP物料资料定义
  125. /// </summary>
  126. /// <param name="whereList"></param>
  127. /// <param name="param"></param>
  128. /// <param name="pageindex"></param>
  129. /// <param name="pagesize"></param>
  130. /// <param name="totalcnt"></param>
  131. /// <returns></returns>
  132. public List<L1Mtrldef> GetErpMtrlPriceList(List<string> whereList, Dictionary<string, object> param,int pageindex,int pagesize,out int totalcnt)
  133. {
  134. var mtrldefList = new List<L1Mtrldef>();
  135. var selectFields = @"row_number() over (order by u_mtrldef.mtrlcode) as rowNum,u_mtrldef.scid,u_mtrldef.mtrlid,u_mtrldef.mtrlcode,u_mtrldef.mtrlname,u_mtrldef.mtrlorigin,u_mtrldef.mtrltype,u_mtrldef.mtrlengname,
  136. u_mtrldef.unit,u_mtrldef.mtrlmode,u_mtrldef.mtrlsectype,u_mtrldef.zxmtrlmode,u_mtrldef.status_config,u_mtrldef.woodcode_config,
  137. u_mtrldef.pcode_config,u_mtrldef.statustype,u_mtrldef.woodcodetype,u_mtrldef.pcodetype,ISNULL(u_erpmtrl_price.price,0) AS price,
  138. u_erpmtrl_price.create_date,u_erpmtrl_price.create_emp,u_erpmtrl_price.update_date,u_erpmtrl_price.update_emp";
  139. var outputFileds = @"rowNum,scid,mtrlid,mtrlcode,mtrlname,mtrlorigin,mtrltype,mtrlengname,unit,mtrlmode,mtrlsectype,zxmtrlmode,status_config,woodcode_config,
  140. pcode_config,statustype,woodcodetype,pcodetype,price,create_date,create_emp,update_date,update_emp";
  141. var selectStr = $@"SELECT {selectFields}
  142. FROM u_mtrldef
  143. LEFT JOIN u_erpmtrl_price ON u_mtrldef.mtrlid = u_erpmtrl_price.mtrlid";
  144. var whereStr = string.Empty;
  145. if (whereList != null && whereList.Count > 0)
  146. {
  147. whereStr = ListEx.GetWhereStr(whereList);
  148. }
  149. var orderStr = "mtrlcode";
  150. totalcnt = 0;
  151. DbSqlHelper.SelectJoin(cmd, selectStr, whereStr, param, orderStr, outputFileds, pageindex,
  152. pagesize, mtrldefList, ref totalcnt);
  153. return mtrldefList;
  154. }
  155. }
  156. }