BasicInfoHelper.cs 8.5 KB

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