InterfaceHelper.cs 75 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621
  1. using JLHHJSvr.BLL;
  2. using JLHHJSvr.Com;
  3. using JLHHJSvr.Com.Model;
  4. using JLHHJSvr.LJException;
  5. using JLHHJSvr.Tools;
  6. using LJLib.DAL.SQL;
  7. using Microsoft.SqlServer.Server;
  8. using Newtonsoft.Json.Linq;
  9. using System;
  10. using System.Collections;
  11. using System.Collections.Generic;
  12. using System.Data.SqlClient;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using System.Web;
  17. using System.Xml.Linq;
  18. namespace JLHHJSvr.Helper
  19. {
  20. internal class InterfaceHelper : HelperBase
  21. {
  22. /// <summary>
  23. /// 床垫接口-保存
  24. /// </summary>
  25. /// <param name="mattress"></param>
  26. /// <param name="mxlist"></param>
  27. /// <param name="qdlist"></param>
  28. /// <exception cref="LJCommonException"></exception>
  29. public void SaveMattressInterface(u_mattress mattress, List<u_mattress_interface> mxlist, List<u_mattress_interface_qd> qdlist)
  30. {
  31. if (mattress.mattressid <= 0)
  32. {
  33. throw new LJCommonException("错误的床垫id");
  34. }
  35. AutoSetMtrlName(mattress, mxlist);
  36. if (string.IsNullOrEmpty(mattress.erp_mtrlcode))
  37. {
  38. throw new LJCommonException("请输入物料名称!");
  39. }
  40. if (mattress.erp_mtrltypeid == null || mattress.erp_mtrltypeid <= 0)
  41. {
  42. throw new LJCommonException("请选择物料类别!");
  43. }
  44. if (mattress.erp_configcodetype == null || mattress.erp_configcodetype <= 0)
  45. {
  46. throw new LJCommonException("请选择配置类型!");
  47. }
  48. DbSqlHelper.Update(cmd, mattress, "erp_mtrlid,erp_mtrltypeid,erp_mtrlcode,erp_mtrlname,erp_mtrlmode,erp_mtrltype,erp_mtrlunit,erp_mtrlengname,erp_configcodetype,old_mtrlname");
  49. // 保存接口数据
  50. var mattressHelper = GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = context.tokendata });
  51. mattressHelper.SaveMattressInterface(mattress.mattressid, mxlist, qdlist);
  52. }
  53. public void AutoSetMtrlName(u_mattress mattress, List<u_mattress_interface> mxlist)
  54. {
  55. string mtrltypename = string.Empty, mtrltypecode = string.Empty;
  56. string mattresstypename = string.Empty, mattresstypecode = string.Empty;
  57. string packtypename = string.Empty, packtypecode = string.Empty;
  58. var materialCodes = new Dictionary<string, string>
  59. {
  60. { "两边单层", "21" },
  61. { "两边直出", "23" },
  62. { "三边加顶", "32" },
  63. { "三边直出", "33" },
  64. { "假三边", "34" },
  65. { "拉假边", "3C" },
  66. { "假三边加顶", "42" },
  67. { "上下假三边", "44" },
  68. { "四边双顶", "45" },
  69. { "四边顶上顶", "46" },
  70. { "四边假分体", "47" }
  71. };
  72. var mattressTypeCodes = new Dictionary<string, string>
  73. {
  74. { "袋装网", "P" },
  75. { "拉丝网", "C" },
  76. { "圆网", "B" }
  77. };
  78. var packTypeCodes = new Dictionary<string, string>
  79. {
  80. { "平压", "A" },
  81. { "卷包", "B" }
  82. };
  83. foreach (var mx in mxlist)
  84. {
  85. if (mx.bj_pzname.IndexOf("床垫类别") > -1)
  86. {
  87. mtrltypename = mx.bj_namemx;
  88. break;
  89. }
  90. }
  91. foreach (var mx in mxlist)
  92. {
  93. if (mx.bj_pzname.IndexOf("床网") > -1)
  94. {
  95. mattresstypename = mx.bj_namemx;
  96. break;
  97. }
  98. }
  99. foreach (var mx in mxlist)
  100. {
  101. if (mx.bj_pzname.IndexOf("包装方式") > -1)
  102. {
  103. packtypename = mx.bj_namemx;
  104. break;
  105. }
  106. }
  107. mtrltypecode = materialCodes.ContainsKey(mtrltypename) ? materialCodes[mtrltypename] : "99";
  108. mattresstypecode = mattressTypeCodes.ContainsKey(mtrltypename) ? mattressTypeCodes[mtrltypename] : "Z";
  109. packtypecode = packTypeCodes.ContainsKey(mtrltypename) ? packTypeCodes[mtrltypename] : "J";
  110. // 获取mxlist最后一项
  111. if (mattress.mattressid > 0)
  112. {
  113. mattress.erp_mtrlname = new StringBuilder().Append(mtrltypecode).Append(mattresstypecode).Append(packtypecode).ToString();
  114. }
  115. }
  116. public List<u_mattress_interface> GetMattressInterfaceList(int mattressid)
  117. {
  118. var interfaceList = new List<u_mattress_interface>();
  119. var selectStr = @"SELECT mattressid
  120. ,printid
  121. ,itemname
  122. ,bj_pzname
  123. ,bj_namemx
  124. ,actual_size
  125. ,sb_craft
  126. ,actual_size_sb
  127. ,erp_pzid
  128. ,ss_rate
  129. ,ls_rate
  130. ,bj_inputtype
  131. FROM u_mattress_interface";
  132. DbSqlHelper.SelectJoin(cmd, selectStr, "mattressid = @mattressid", new Dictionary<string, object>() { { "@mattressid", mattressid } }, "printid", "mattressid,printid,itemname,bj_pzname,bj_namemx,actual_size,sb_craft,actual_size_sb,erp_pzid,ss_rate,ls_rate,bj_inputtype", 0, 0, interfaceList);
  133. if(interfaceList.Count <= 0)
  134. {
  135. interfaceList = RefreshMattressInterfaceList(mattressid);
  136. }
  137. MattressInterfaceFindERPPz(mattressid, interfaceList);
  138. return interfaceList;
  139. }
  140. public List<u_mattress_interface_qd> GetMattressInterfaceQdList(int mattressid)
  141. {
  142. var qdList = new List<u_mattress_interface_qd>();
  143. var selectStr = @"SELECT u_mattress_interface_qd.mattressid
  144. ,u_mattress_interface_qd.printid
  145. ,u_mattress_interface_qd.itemname
  146. ,u_mattress_interface_qd.bj_pzname
  147. ,u_mattress_interface_qd.bj_pzname_mx
  148. ,u_mattress_interface_qd.bj_pzname_mx_mx
  149. ,u_mattress_interface_qd.mtrlid
  150. ,u_mattress_interface_qd.erp_mtrlid
  151. ,u_mattress_interface_qd.useqty
  152. ,u_mattress_interface_qd.dscrp
  153. ,u_mtrl_price.name AS mtrlname
  154. ,u_mattress_interface_qd.actual_useqty
  155. ,u_mattress_interface_qd.qd_actual_size
  156. ,u_mattress_interface_qd.qd_pfgroupqty
  157. ,u_mattress_interface_qd.wrkgrpid
  158. ,u_mattress_interface_qd.ss_rate
  159. ,u_mattress_interface_qd.ls_rate
  160. ,u_mattress_interface_qd.sh_rate
  161. FROM u_mattress_interface_qd
  162. LEFT JOIN u_mtrl_price ON u_mtrl_price.mtrlid = u_mattress_interface_qd.mtrlid";
  163. var outputFields = "mattressid,printid,itemname,bj_pzname,bj_pzname_mx,bj_pzname_mx_mx,mtrlid,erp_mtrlid,useqty,dscrp,mtrlname,actual_useqty,qd_actual_size,qd_pfgroupqty,wrkgrpid,ss_rate,ls_rate,sh_rate";
  164. DbSqlHelper.SelectJoin(cmd, selectStr, "mattressid = @mattressid", new Dictionary<string, object>() { { "@mattressid", mattressid } }, "printid", outputFields, 0, 0, qdList);
  165. if (qdList.Count <= 0)
  166. {
  167. qdList = RefreshMattressInterfaceQdList(mattressid);
  168. }
  169. return qdList;
  170. }
  171. #region 导入配置方法
  172. /// <summary>
  173. /// 刷新带出配置
  174. /// </summary>
  175. /// <param name="mattressid"></param>
  176. /// <returns></returns>
  177. public List<u_mattress_interface> RefreshMattressInterfaceList(int mattressid)
  178. {
  179. var interfaceList = new List<u_mattress_interface>();
  180. // 导入配置
  181. ImportMattressInterfaceList(mattressid, interfaceList);
  182. MattressInterfaceFindERPPz(mattressid, interfaceList);
  183. return interfaceList;
  184. }
  185. /// <summary>
  186. /// 导入产品配置
  187. /// </summary>
  188. /// <param name="mattressid"></param>
  189. /// <exception cref="LJCommonException"></exception>
  190. public void ImportMattressInterfaceList(int mattressid, List<u_mattress_interface> interfaceList)
  191. {
  192. if (mattressid <= 0)
  193. {
  194. throw new LJCommonException("床垫id有误");
  195. }
  196. var mattressHelper = GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = context.tokendata });
  197. var mattress = mattressHelper.GetMattress(mattressid);
  198. var mattress_type = new u_mattress_type() { mattresstypeid = mattress.mattresstypeid };
  199. DbSqlHelper.SelectOne(cmd, mattress_type, "typename");
  200. var mxlist = mattressHelper.GetMattressMxMtrl(mattressid, new List<string>() { "u_mattress_formula.formulatype IN (0,1,2,3,99,104)" });
  201. var mxlist_103 = mattressHelper.GetMattressMxMtrl(mattressid, new List<string>() { "u_mattress_formula.formulatype = 103" });
  202. var mxlist_101 = mattressHelper.GetMattressMxMtrl(mattressid, new List<string>() { "u_mattress_formula.formulatype = 101" });
  203. // 高度
  204. interfaceList.Add(InserMattressInterfacePz("床垫", "高度", 2, new string[] { $"{mattress.mattress_height}" }));
  205. // 参考外观
  206. interfaceList.Add(InserMattressInterfacePz("床垫", "参考外观", 1, new string[] { "" }));
  207. // 尺寸
  208. mattress.erp_mtrlcode = $"{mattress.mattress_width}*{mattress.mattress_length}*{mattress.mattress_height}";
  209. interfaceList.Add(InserMattressInterfacePz("床垫", "尺寸", 2, new string[] { mattress.erp_mtrlcode }));
  210. // 床垫类别
  211. interfaceList.Add(InserMattressInterfacePz("床垫", "床垫类别", 2, new string[] { mattress_type.typename }));
  212. // 拆装类型
  213. var name_arr = new string[1];
  214. name_arr[0] = string.Empty;
  215. if (mattress.if_m_chai == 1) name_arr[0] = AppendToString(name_arr[0], "面拆");
  216. if (mattress.if_z_chai == 1) name_arr[0] = AppendToString(name_arr[0], "中拆");
  217. if (mattress.if_d_chai == 1) name_arr[0] = AppendToString(name_arr[0], "底拆");
  218. interfaceList.Add(InserMattressInterfacePz("床垫", "拆装类型", 1, name_arr));
  219. // 床垫分类
  220. name_arr[0] = string.Empty;
  221. if (mattress.if_haimian_type == 1) name_arr[0] = AppendToString(name_arr[0], "海绵床垫");
  222. else name_arr[0] = AppendToString(name_arr[0], "弹簧床垫");
  223. if (mattress.if_zhedie_type == 1) name_arr[0] = AppendToString(name_arr[0], "折叠床垫");
  224. interfaceList.Add(InserMattressInterfacePz("床垫", "床垫分类", 1, name_arr));
  225. // 外观布套做法
  226. name_arr[0] = string.Empty;
  227. if (mattress.if_m_wbutao_way == 1) name_arr[0] = AppendToString(name_arr[0], $"面层向大侧覆盖{mattress.s_m_cover_qty}CM、大侧向底层覆盖{mattress.z_m_cover_qty}CM、底层向大侧覆盖{mattress.x_m_cover_qty}CM");
  228. interfaceList.Add(InserMattressInterfacePz("床垫", "外观布套做法", 1, name_arr));
  229. // 边带
  230. name_arr[0] = string.Empty;
  231. interfaceList.Add(InserMattressInterfacePz("床垫", "边带", 0, name_arr));
  232. #region 面料类清单导入 AutoSetFormulaTypeZeroPz()需要优化
  233. AutoSetFormulaTypeZeroPz(mxlist, interfaceList);
  234. interfaceList.Add(InserMattressInterfacePz("车位说明", "车位说明", 1, name_arr));
  235. #endregion
  236. #region 垫层类清单导入
  237. AutoSetFormulaTypeOnePz(mxlist, interfaceList);
  238. #endregion
  239. #region 辅料类清单导入
  240. AutoSetFormulaTypeTwoPz(mxlist, interfaceList);
  241. #endregion
  242. #region 包装类清单导入
  243. AutoSetFormulaTypeThreePz(mattress, mxlist, interfaceList);
  244. #endregion
  245. #region 内布套类清单导入
  246. AutoSetFormulaType101Pz(mattress, mxlist_103, interfaceList);
  247. #endregion
  248. #region 自定义配置导入
  249. if(mattress.erp_configcodetype != null && mattress.erp_configcodetype > 0)
  250. {
  251. var erpHelper = HelperBase.GetHelper<ERPHelper>(null);
  252. var parameters = new JObject();
  253. parameters.Add("dsname", "web_configure_code_list");
  254. var queryparams = new JObject();
  255. queryparams.Add("arg_configcodetype", mattress.erp_configcodetype);
  256. queryparams.Add("arg_ifpack", 1);
  257. parameters.Add("queryparams", queryparams);
  258. var resultList = erpHelper.GetERPList<erp_configure_code>("CommonDynamicSelect", parameters);
  259. foreach(var result in resultList)
  260. {
  261. var pzname = result.name;
  262. interfaceList.Add(InserMattressInterfacePz("自定义", pzname, 1, new string[] { "" }));
  263. }
  264. }
  265. #endregion
  266. }
  267. public void MattressInterfaceFindERPPz(int mattressid, List<u_mattress_interface> interfaceList)
  268. {
  269. var mattress = new u_mattress() { mattressid = mattressid };
  270. DbSqlHelper.SelectOne(cmd, mattress, "erp_configcodetype");
  271. MattressInterfaceFindERPPz(mattress, interfaceList);
  272. }
  273. public void MattressInterfaceFindERPPz(u_mattress mattress,List<u_mattress_interface> interfaceList)
  274. {
  275. var typeList = new List<erp_configure_code>();
  276. foreach(var item in interfaceList)
  277. {
  278. typeList.Add(new erp_configure_code() { typeid = mattress.erp_configcodetype,name = item.bj_pzname });
  279. }
  280. var erpHelper = HelperBase.GetHelper<ERPHelper>(null);
  281. var parameters = new JObject();
  282. parameters.Add("typeList", JToken.FromObject(typeList));
  283. var resultList = erpHelper.GetERPList<erp_configure_code>("GetL1ConfigureCode", parameters);
  284. for (var i = 0; i < interfaceList.Count; i++)
  285. {
  286. interfaceList[i].printid = i + 1;
  287. foreach (var result in resultList)
  288. {
  289. if (result.pzid > 0)
  290. {
  291. interfaceList[i].erp_pzid = result.pzid;
  292. interfaceList[i].erp_pzcode = result.pzcode;
  293. interfaceList[i].erp_pzname = result.name;
  294. }
  295. if (interfaceList[i].bj_inputtype != 2) interfaceList[i].bj_inputtype = result.inputtype;
  296. }
  297. }
  298. }
  299. /// <summary>
  300. /// 初始化配置信息
  301. /// </summary>
  302. /// <param name="itemname"></param>
  303. /// <param name="bj_pzname"></param>
  304. /// <param name="inputtype"></param>
  305. /// <param name="names"></param>
  306. /// <returns></returns>
  307. public u_mattress_interface InserMattressInterfacePz(string itemname, string bj_pzname, byte inputtype, string[] names)
  308. {
  309. var mattress_interface = new u_mattress_interface()
  310. {
  311. itemname = itemname,
  312. bj_pzname = bj_pzname,
  313. bj_inputtype = inputtype,
  314. bj_namemx = names == null ? string.Empty : SetInterfacePzName(names)
  315. };
  316. return mattress_interface;
  317. }
  318. private string SetInterfacePzName(string[] names)
  319. {
  320. var result = string.Empty;
  321. foreach (var name in names)
  322. {
  323. if (string.IsNullOrEmpty(name)) continue;
  324. result = AppendToString(result, name);
  325. }
  326. return result;
  327. }
  328. private void AutoSetFormulaTypeZeroPz(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface> interfaceList)
  329. {
  330. var powerDict = new Dictionary<string, int[]>()
  331. {
  332. {"面裥绵",new int[] { 0, 40, 50, 60, 70, 80 } },
  333. {"底裥绵",new int[] { 1, 41, 51, 61, 71, 81 } },
  334. {"顶布裥棉1",new int[] { 0, 40, 50, 60, 70, 80 } },
  335. {"顶布裥棉2",new int[] { 0, 40, 50, 60, 70, 80 } },
  336. {"顶布裥棉3",new int[] { 0, 40, 50, 60, 70, 80 } },
  337. {"顶布裥棉4",new int[] { 0, 40, 50, 60, 70, 80 } },
  338. {"普通大侧",new int[] { 2, 42, 52, 62, 72, 82 } },
  339. {"上下拼侧1",new int[] { 2, 42, 52, 62, 72, 82 } },
  340. {"上下拼侧2",new int[] { 2, 42, 52, 62, 72, 82 } },
  341. {"上下拼侧3",new int[] { 2, 42, 52, 62, 72, 82 } },
  342. {"左右拼侧1",new int[] { 2, 42, 52, 62, 72, 82 } },
  343. {"左右拼侧2",new int[] { 2, 42, 52, 62, 72, 82 } },
  344. {"左右拼侧3",new int[] { 2, 42, 52, 62, 72, 82 } },
  345. {"小侧1_EMPTY",new int[] { 3, 43, 53, 63, 73, 83 } },
  346. {"小侧1",new int[] { 3, 43, 53, 63, 73, 83 } },
  347. {"小侧1-上下拼侧1",new int[] { 3, 43, 53, 63, 73, 83 } },
  348. {"小侧1-上下拼侧2",new int[] { 3, 43, 53, 63, 73, 83 } },
  349. {"小侧1-上下拼侧3",new int[] { 3, 43, 53, 63, 73, 83 } },
  350. {"小侧2",new int[] { 3, 43, 53, 63, 73, 83 } },
  351. {"小侧3",new int[] { 3, 43, 53, 63, 73, 83 } },
  352. {"V侧1_EMPTY",new int[] { 4, 44, 54, 64, 74, 84 } },
  353. {"V侧1",new int[] { 4, 44, 54, 64, 74, 84 } }
  354. };
  355. var chastrArrDict = new Dictionary<string, string[]>()
  356. {
  357. {"面裥绵",new string[] { "裥面", "面层裥棉", "面层裥棉图案", "面层裥面说明" } },
  358. {"底裥绵",new string[] { "裥底", "底层裥棉", "底层裥棉图案", "底层裥棉说明" } },
  359. {"顶布裥棉1",new string[] { "顶布裥棉", "", "顶布裥棉1图案", "顶布裥棉1说明" } },
  360. {"顶布裥棉2",new string[] { "顶布裥棉", "", "顶布裥棉2图案", "顶布裥棉2说明" } },
  361. {"顶布裥棉3",new string[] { "顶布裥棉", "", "顶布裥棉3图案", "顶布裥棉3说明" } },
  362. {"顶布裥棉4",new string[] { "顶布裥棉","", "顶布裥棉4图案", "顶布裥棉4说明" } },
  363. {"普通大侧",new string[] { "大侧", "大侧裥棉", "大侧裥棉图案" } },
  364. {"上下拼侧1",new string[] {"大侧", "大侧-上下拼侧1", "大侧-上下拼侧1", "大侧-上下拼侧1高度"} },
  365. {"上下拼侧2",new string[] { "大侧", "大侧-上下拼侧2", "大侧-上下拼侧2", "大侧-上下拼侧2高度" } },
  366. {"上下拼侧3",new string[] { "大侧", "大侧-上下拼侧3", "大侧-上下拼侧3", "大侧-上下拼侧3高度" } },
  367. {"左右拼侧1",new string[] { "大侧", "大侧-左右拼侧1", "大侧-左右拼侧1裥棉图案", "大侧-左右拼侧1长度" } },
  368. {"左右拼侧2",new string[] { "大侧", "大侧-左右拼侧2", "大侧-左右拼侧2裥棉图案", "大侧-左右拼侧2长度" } },
  369. {"左右拼侧3",new string[] { "大侧", "大侧-左右拼侧3", "大侧-左右拼侧3裥棉图案", "大侧-左右拼侧3长度", "大侧说明" } },
  370. {"小侧1_EMPTY",new string[] { "小侧", "小侧1裥棉", "小侧1裥棉图案" } },
  371. {"小侧1",new string[] { "小侧", "小侧1裥棉", "小侧1裥棉图案" } },
  372. {"小侧1-上下拼侧1",new string[] { "小侧", "小侧1-上下拼侧1裥棉", "小侧1-上下拼侧1裥棉图案" } },
  373. {"小侧1-上下拼侧2",new string[] { "小侧", "小侧1-上下拼侧2裥棉", "小侧1-上下拼侧2裥棉图案" } },
  374. {"小侧1-上下拼侧3",new string[] { "小侧", "小侧1-上下拼侧3裥棉", "小侧1-上下拼侧3裥棉图案" } },
  375. {"小侧2",new string[] { "小侧", "小侧2裥棉", "小侧2裥棉图案" } },
  376. {"小侧3",new string[] { "小侧", "小侧3裥棉", "小侧3裥棉图案", "小侧说明" } },
  377. {"V侧1_EMPTY",new string[] { "V侧", "V侧1裥棉", "V侧1裥棉图案" } },
  378. {"V侧1",new string[] { "V侧", "V侧1裥棉", "V侧1裥棉图案" } },
  379. {"V侧2",new string[] { "V侧", "V侧2裥棉", "V侧2裥棉图案" } },
  380. {"V侧3",new string[] { "V侧", "V侧3裥棉", "V侧3裥棉图案", "V侧说明" } }
  381. };
  382. var jianmianList = mxlist.Where(t => t.formulatype == 0).ToList();
  383. #region wf_import_qingdan + wf_import_qingdan_1 面料部分
  384. foreach (var item in powerDict)
  385. {
  386. SetFormulaTypeZeroPz(jianmianList, interfaceList, item.Value, item.Key, chastrArrDict[item.Key]);
  387. }
  388. #endregion
  389. #region wf_import_qingdan_next 面料部分
  390. // 拉手
  391. var lashouList = jianmianList.Where(t => t.formulakind == 5).ToList();
  392. for (int i = 0; i < lashouList.Count; i++)
  393. {
  394. var mx = lashouList[i];
  395. if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
  396. {
  397. interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", $"拉手{i + 1}做法", 1, new string[] { $"{mx.qty.Value.ToString("#,##0.0#")}只{mx.mtrlname}" }));
  398. interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", $"拉手{i + 1}刺绣", 0, new string[] { "" }));
  399. }
  400. }
  401. // 刺绣
  402. var cixiuList = jianmianList.Where(t => t.formulakind == 6).ToList();
  403. for (int i = 0; i < cixiuList.Count; i++)
  404. {
  405. var mx = cixiuList[i];
  406. if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
  407. {
  408. interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", $"侧刺绣{i + 1}做法", 1, new string[] { "" }));
  409. interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", $"侧刺绣{i + 1}位置", 0, new string[] { "" }));
  410. }
  411. }
  412. // 大侧压压布
  413. var dcyybList = jianmianList.Where(t => t.formulakind == 7).ToList();
  414. for (int i = 0; i < dcyybList.Count; i++)
  415. {
  416. var mx = dcyybList[i];
  417. if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
  418. {
  419. interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", $"大侧压压布{i + 1}", 1, new string[] { $"{mx.qty.Value.ToString("#,##0.0#")}米{mx.mtrlname}" }));
  420. }
  421. }
  422. // 大侧压边带
  423. var dcybdList = jianmianList.Where(t => t.formulakind == 8).ToList();
  424. for (int i = 0; i < dcybdList.Count; i++)
  425. {
  426. var mx = dcybdList[i];
  427. if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
  428. {
  429. interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", $"大侧压边带{i + 1}", 1, new string[] { $"{mx.qty.Value.ToString("#,##0.0#")}米{mx.mtrlname}" }));
  430. }
  431. }
  432. // 大侧压织带
  433. var dcyzdList = jianmianList.Where(t => t.formulakind == 9).ToList();
  434. for (int i = 0; i < dcyzdList.Count; i++)
  435. {
  436. var mx = dcyzdList[i];
  437. if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
  438. {
  439. interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", $"大侧压织带{i + 1}", 1, new string[] { $"{mx.qty.Value.ToString("#,##0.0#")}米{mx.mtrlname}" }));
  440. }
  441. }
  442. // 大侧压上下压线
  443. var dcysxyxList = jianmianList.Where(t => t.formulakind == 10).ToList();
  444. for (int i = 0; i < dcysxyxList.Count; i++)
  445. {
  446. var mx = dcysxyxList[i];
  447. if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
  448. {
  449. interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", $"大侧压上下压线{i + 1}", 1, new string[] { $"{mx.qty.Value.ToString("#,##0.0#")}米{mx.mtrlname}" }));
  450. }
  451. }
  452. // 车花边
  453. var chbList = jianmianList.Where(t => t.formulakind == 205).ToList();
  454. for (int i = 0; i < chbList.Count; i++)
  455. {
  456. var mx = chbList[i];
  457. if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
  458. {
  459. interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", "车花边", 1, new string[] { $"{mx.qty.Value.ToString("#,##0.0#")}米{mx.mtrlname}" }));
  460. }
  461. }
  462. // 防火线
  463. var fhxList = jianmianList.Where(t => t.formulakind == 30).ToList();
  464. for (int i = 0; i < fhxList.Count; i++)
  465. {
  466. var mx = fhxList[i];
  467. if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
  468. {
  469. interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", "防火线", 1, new string[] { mx.mtrlname }));
  470. }
  471. }
  472. // 拉链
  473. var llList = jianmianList.Where(t => t.formulakind == 202).ToList();
  474. for (int i = 0; i < llList.Count; i++)
  475. {
  476. var mx = llList[i];
  477. if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
  478. {
  479. interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", "拉链", 1, new string[] { $"{mx.qty.Value.ToString("#,##0.0#")}米{mx.mtrlname}" }));
  480. }
  481. }
  482. #endregion
  483. }
  484. private void SetFormulaTypeZeroPz(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface> interfaceList, int[] powerArr, string key, string[] chastrArr)
  485. {
  486. var mianList1 = new HashSet<string> { "面裥绵", "底裥绵" };
  487. var mianList2 = new string[4] { "顶布裥棉1", "顶布裥棉2", "顶布裥棉3", "顶布裥棉4" };
  488. var mianList3 = new HashSet<string> { "普通大侧", "上下拼侧1", "上下拼侧2", "上下拼侧3", "左右拼侧1", "左右拼侧2", "左右拼侧3", "小侧1", "小侧2", "小侧3" };
  489. var name_arr = new string[5];
  490. foreach (var mx in mxlist)
  491. {
  492. SetFormulaTypeZeroPzName(mx, key, powerArr, name_arr);
  493. }
  494. if (mianList2.Contains(key))
  495. {
  496. for (int i = 0; i < mianList2.Length; i++)
  497. {
  498. DingBuLianMian.SetValue(name_arr[i], i, 0);
  499. }
  500. }
  501. var sb = new StringBuilder();
  502. foreach (var name2 in name_arr)
  503. {
  504. sb.Append(name2);
  505. }
  506. if (sb.Length > 0)
  507. {
  508. if (!string.IsNullOrEmpty(chastrArr[1])) interfaceList.Add(InserMattressInterfacePz(chastrArr[0], chastrArr[1], 2, name_arr));
  509. interfaceList.Add(InserMattressInterfacePz(chastrArr[0], chastrArr[2], 1, new string[] { "" }));
  510. if (chastrArr.Length > 3) interfaceList.Add(InserMattressInterfacePz(chastrArr[0], chastrArr[3], 1, new string[] { "" }));
  511. }
  512. foreach (var name in chastrArr)
  513. {
  514. if (string.IsNullOrEmpty(name)) continue;
  515. if (name.Contains("说明"))
  516. {
  517. interfaceList.Add(InserMattressInterfacePz(chastrArr[0], name, 1, new string[] { "" }));
  518. }
  519. }
  520. }
  521. private void SetFormulaTypeZeroPzName(u_mattress_mx_mtrl mx, string key, int[] powerArr, string[] name_arr)
  522. {
  523. if (key.Contains("_EMPTY")) key = "";
  524. if (mx.mtrlid > 0 && key.Equals(mx.chastr) && powerArr.Contains(mx.formulakind.Value))
  525. {
  526. if (mx.formulakind == 0 || mx.formulakind == 1 || mx.formulakind == 2 || mx.formulakind == 3)
  527. {
  528. name_arr[0] = SplitNameCount(mx.mtrlname, Convert.ToInt32(mx.qty.Value));
  529. }
  530. if (mx.formulakind == 40 || mx.formulakind == 41 || mx.formulakind == 42 || mx.formulakind == 43)
  531. {
  532. name_arr[1] = SplitNameCount(mx.mtrlname, Convert.ToInt32(mx.qty.Value));
  533. }
  534. if (mx.formulakind == 50 || mx.formulakind == 51 || mx.formulakind == 52 || mx.formulakind == 53)
  535. {
  536. var mtrlname_temp = mx.mtrlname;
  537. if (!(mx.mtrlname.IndexOf("分") > -1 && mx.thickness == 0 || mx.if_inputqty == 1))
  538. {
  539. mtrlname_temp = $"{mx.thickness.Value.ToString("#,##0.0#")}分{mx.mtrlname}";
  540. }
  541. name_arr[2] = SplitNameCount(mtrlname_temp, Convert.ToInt32(mx.qty.Value));
  542. }
  543. if (mx.formulakind == 60 || mx.formulakind == 61 || mx.formulakind == 62 || mx.formulakind == 63)
  544. {
  545. name_arr[3] = SplitNameCount(mx.mtrlname, Convert.ToInt32(mx.qty.Value));
  546. }
  547. if (mx.formulakind == 80 || mx.formulakind == 81)
  548. {
  549. name_arr[0] = AppendToString(name_arr[0], mx.mtrlname);
  550. }
  551. }
  552. }
  553. private void AutoSetFormulaTypeOnePz(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface> interfaceList)
  554. {
  555. var diancengList = mxlist.Where(t => t.formulatype == 1).ToList();
  556. var kindDict = new Dictionary<int, string>()
  557. {
  558. { 32,"垫层" },
  559. { 12,"顶布" },
  560. { 13,"毡类" },
  561. { 14,"打底无纺布" },
  562. { 29,"网面布料" },
  563. { 999,"床网" },
  564. { 1201,"顶布裥棉" },
  565. };
  566. var chastrSet = new HashSet<string>() { "大侧", "小侧1", "小侧2", "小侧3", "V侧1", "V侧2", "V侧3" };
  567. var countDict = new Dictionary<string, int>();
  568. foreach (var cha in chastrSet)
  569. {
  570. foreach (var kind in kindDict)
  571. {
  572. countDict.Add($"{cha}-{kind.Value}", 0);
  573. }
  574. }
  575. foreach (var mx in diancengList)
  576. {
  577. var key = $"{mx.chastr}-{kindDict[mx.formulakind.Value]}";
  578. if (mx.formulakind == 999)
  579. {
  580. this.ProcessChuangWangPz(mx, interfaceList, mx.chastr, ++countDict[key]);
  581. }
  582. else if (mx.mtrlid > 0 && mx.formulakind == 1201)
  583. {
  584. this.ProcessDingbuLianMianPz(mx, interfaceList, mx.chastr, ++countDict[key]);
  585. }
  586. else if (mx.mtrlid > 0 && new int[] { 32, 12, 13, 14, 29 }.Contains(mx.formulakind.Value))
  587. {
  588. this.ProcessWangMianBLPz(mx, interfaceList, mx.chastr, kindDict[mx.formulakind.Value], ++countDict[key]);
  589. }
  590. }
  591. if (countDict["大侧-垫层"] > 0)
  592. {
  593. interfaceList.Add(InserMattressInterfacePz("垫层", "大侧垫层生产说明", 1, new string[1]));
  594. }
  595. if (countDict["小侧1-垫层"] > 0)
  596. {
  597. interfaceList.Add(InserMattressInterfacePz("垫层", "小侧垫层生产说明", 1, new string[1]));
  598. }
  599. if (countDict["V侧1-垫层"] > 0)
  600. {
  601. interfaceList.Add(InserMattressInterfacePz("垫层", "V侧垫层生产说明", 1, new string[1]));
  602. }
  603. }
  604. /// <summary>
  605. /// 床网
  606. /// </summary>
  607. /// <param name="mx"></param>
  608. /// <param name="interfaceList"></param>
  609. /// <param name="chastr"></param>
  610. /// <param name="count"></param>
  611. private void ProcessChuangWangPz(u_mattress_mx_mtrl mx, List<u_mattress_interface> interfaceList, string chastr, int count)
  612. {
  613. var name_arr = new string[5];
  614. int bednetid = 0;
  615. cmd.CommandText = @"SELECT u_bednetmx.bednet_height,u_bednetmx.bednetid
  616. FROM u_bednetmx
  617. INNER JOIN (
  618. SELECT mtrlid
  619. FROM u_mattress_mx_mtrl
  620. INNER JOIN u_mattress_formula ON u_mattress_formula.formulaid = u_mattress_mx_mtrl.formulaid
  621. WHERE u_mattress_formula.formulakind = 99
  622. AND u_mattress_mx_mtrl.mattressid = @mattressid
  623. AND u_mattress_mx_mtrl.mtrlid > 0
  624. ) v_mattress_mx_mtrl ON u_bednetmx.bednetid = v_mattress_mx_mtrl.mtrlid";
  625. cmd.Parameters.Clear();
  626. cmd.Parameters.AddWithValue("@mattressid", mx.mattressid);
  627. using (var reader = cmd.ExecuteReader())
  628. {
  629. while (reader.Read())
  630. {
  631. decimal height = Convert.ToDecimal(reader["bednet_height"]);
  632. if (height == mx.thickness) bednetid = Convert.ToInt32(reader["bednetid"]);
  633. }
  634. }
  635. if (bednetid > 0)
  636. {
  637. var bednetHelper = HelperBase.GetHelper<BedNetHelper>(cmd);
  638. var bednetQdList = bednetHelper.GetBedNetQingDan(bednetid);
  639. if (bednetQdList.Any())
  640. {
  641. name_arr[0] = bednetQdList[0].pznamemx;
  642. name_arr[0] += "丨erp编码:";
  643. cmd.CommandText = @"SELECT u_mattress.erp_mtrlcode
  644. FROM u_mattress_mx_mtrl
  645. INNER JOIN u_mattress_formula ON u_mattress_formula.formulaid = u_mattress_mx_mtrl.formulaid
  646. INNER JOIN u_mattress ON u_mattress.mattressid = u_mattress_mx_mtrl.mattressid
  647. WHERE u_mattress_formula.formulakind = 99
  648. AND u_mattress.bcptypeid <> 0
  649. AND u_mattress_mx_mtrl.mtrlid = @bednetid";
  650. cmd.Parameters.Clear();
  651. cmd.Parameters.AddWithValue("@bednetid", bednetid);
  652. using(var reader = cmd.ExecuteReader())
  653. {
  654. if (reader.Read())
  655. {
  656. name_arr[0] += Convert.ToString(reader["erp_mtrlcode"]);
  657. }
  658. }
  659. }
  660. }
  661. if (FuncPowerHelper.CheckFuncPower(cmd, context.tokendata.userid, 98) && "super".Equals(context.tokendata.username.ToLower()))
  662. {
  663. interfaceList.Add(InserMattressInterfacePz("垫层", $"{chastr}-床网{count}", 2, name_arr));
  664. }
  665. else
  666. {
  667. interfaceList.Add(InserMattressInterfacePz("垫层", $"{chastr}-床网{count}", 1, name_arr));
  668. }
  669. interfaceList.Add(InserMattressInterfacePz("垫层", $"{chastr}-床网{count}生产说明", 1, new string[] { "" }));
  670. interfaceList.Add(InserMattressInterfacePz("垫层", $"{chastr}-床网{count}包边海绵条", 1, new string[] { "" }));
  671. }
  672. /// <summary>
  673. /// 网面布料 / 打底无纺布 / 毡类 / 顶布 / 垫层
  674. /// </summary>
  675. /// <param name="mx"></param>
  676. /// <param name="interfaceList"></param>
  677. /// <param name="chastr"></param>
  678. /// <param name="count"></param>
  679. private void ProcessWangMianBLPz(u_mattress_mx_mtrl mx, List<u_mattress_interface> interfaceList, string chastr, string typename, int count)
  680. {
  681. var name_arr = new string[5];
  682. var mtrlname_temp = mx.mtrlname;
  683. var chastr_temp = string.Empty;
  684. if ("顶布".Equals(typename) && count <= 1)
  685. {
  686. chastr_temp = $"{chastr}-{typename}";
  687. }
  688. else
  689. {
  690. chastr_temp = $"{chastr}-{typename}{count}";
  691. }
  692. if ((!mx.mtrlname.Contains("分") && mx.thickness > 0) || ("垫层".Equals(typename)))
  693. {
  694. mtrlname_temp = $"{mx.thickness.Value.ToString("#,##0.0#")}分{mx.mtrlname}";
  695. }
  696. name_arr[0] = mtrlname_temp;
  697. interfaceList.Add(InserMattressInterfacePz("垫层", chastr_temp, 2, name_arr));
  698. }
  699. /// <summary>
  700. /// 顶布裥棉
  701. /// </summary>
  702. /// <param name="mx"></param>
  703. /// <param name="interfaceList"></param>
  704. /// <param name="count"></param>
  705. private void ProcessDingbuLianMianPz(u_mattress_mx_mtrl mx, List<u_mattress_interface> interfaceList, string chastr, int count)
  706. {
  707. string chastr_temp = string.Empty;
  708. string ls_temp = "";
  709. string[] name_arr = new string[5];
  710. if ("顶布裥棉1".Equals(mx.mtrlname))
  711. {
  712. chastr_temp = $"{chastr}-顶布裥棉";
  713. for (int i = 0; i < DingBuLianMian.GetLength(0); i++)
  714. {
  715. name_arr[i] = DingBuLianMian[0, i];
  716. }
  717. }
  718. else if ("顶布裥棉2".Equals(mx.mtrlname))
  719. {
  720. chastr_temp = $"{chastr}-顶布裥棉2";
  721. for (int i = 0; i < DingBuLianMian.GetLength(0); i++)
  722. {
  723. name_arr[i] = DingBuLianMian[1, i];
  724. }
  725. }
  726. else if ("顶布裥棉3".Equals(mx.mtrlname))
  727. {
  728. chastr_temp = $"{chastr}-顶布裥棉3";
  729. for (int i = 0; i < DingBuLianMian.GetLength(0); i++)
  730. {
  731. name_arr[i] = DingBuLianMian[2, i];
  732. }
  733. }
  734. else if ("顶布裥棉4".Equals(mx.mtrlname))
  735. {
  736. chastr_temp = $"{chastr}-顶布裥棉4";
  737. for (int i = 0; i < DingBuLianMian.GetLength(0); i++)
  738. {
  739. name_arr[i] = DingBuLianMian[3, i];
  740. }
  741. }
  742. interfaceList.Add(InserMattressInterfacePz("垫层", chastr_temp, 2, name_arr));
  743. }
  744. private void AutoSetFormulaTypeTwoPz(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface> interfaceList)
  745. {
  746. var fuliaoList = mxlist.Where(t => t.formulatype == 2).ToList();
  747. var nameSet = new HashSet<string>(new string[] {
  748. "白色无字包角", "保用卡", "采购小标", "打钮钮扣", "打印小标", "合格证", "画纸", "角网+拉链",
  749. "开箱刀+开箱说明", "开箱说明+开箱刀", "气钮", "吊标", "说明书", "斜标", "正标", "织唛",
  750. "织唛斜标", "客供标", "空白牛皮纸包角", "空白珍珠包角"
  751. });
  752. var extraSet = new HashSet<string>(new string[] { "采购小标", "打印小标", "合格证", "吊标", "斜标", "正标", "织唛", "织唛斜标", "客供标" });
  753. var specialSet = new HashSet<string>(new string[] { "打钮钮扣", "气钮" });
  754. foreach (var mx in fuliaoList)
  755. {
  756. if (mx.mtrlid > 0)
  757. {
  758. int cnt = Convert.ToInt32(Math.Abs(mx.qty.Value));
  759. // 处理特殊辅料
  760. if (specialSet.Contains(mx.mtrlname))
  761. {
  762. interfaceList.Add(InserMattressInterfacePz("辅料", $"{mx.mtrlname}", 1, new string[] { $"{cnt.ToString("#,##0.0#")}个" }));
  763. continue; // 跳过后续的处理
  764. }
  765. // 处理其他辅料
  766. if (nameSet.Contains(mx.mtrlname))
  767. {
  768. for (int i = 1; i <= cnt; i++)
  769. {
  770. // 添加辅料接口
  771. interfaceList.Add(InserMattressInterfacePz("辅料", $"{mx.mtrlname}{i}", 1, new string[] { "" }));
  772. // 如果是额外的辅料,添加位置接口
  773. if (extraSet.Contains(mx.mtrlname))
  774. {
  775. interfaceList.Add(InserMattressInterfacePz("辅料", $"{mx.mtrlname}{i}位置", 0, new string[] { "" }));
  776. }
  777. }
  778. }else if(mx.formulakind == 15 && !nameSet.Contains(mx.mtrlname))
  779. {
  780. for (int i = 1; i <= cnt; i++)
  781. {
  782. interfaceList.Add(InserMattressInterfacePz("辅料", $"{mx.mtrlname}{i}", 1, new string[] { "" }));
  783. interfaceList.Add(InserMattressInterfacePz("辅料", $"{mx.mtrlname}{i}位置", 0, new string[] { "" }));
  784. }
  785. }
  786. }
  787. }
  788. }
  789. private void AutoSetFormulaTypeThreePz(u_mattress mattress, List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface> interfaceList)
  790. {
  791. // 筛选 formulatype 为 3 的物料
  792. var bzList = mxlist.Where(t => t.formulatype == 3).ToList();
  793. var chastrDict = new Dictionary<int, string>
  794. {
  795. {16, "PE袋"},
  796. {17, "外层PE"},
  797. {18, "PVC"},
  798. {19, "卷包包装"},
  799. {20, "牛皮纸袋"},
  800. {21, "蓝色PE护角"},
  801. {22, "无纺布袋"},
  802. {23, "牛皮袋护角"},
  803. {24, "编织袋"},
  804. {27, "拉手脚轮"},
  805. {201, "无纺布护角"}
  806. };
  807. var countDict = new Dictionary<int, int>
  808. {
  809. {16, 0}
  810. };
  811. // 外观
  812. interfaceList.Add(InserMattressInterfacePz("包装", "包装方式", 1, new string[] { Enum.GetName(typeof(PackType), mattress.packtype) }));
  813. foreach (var mx in bzList)
  814. {
  815. if (mx.mtrlid > 0 && chastrDict.TryGetValue(mx.formulakind.GetValueOrDefault(), out var chastr))
  816. {
  817. var name_arr = new string[1];
  818. if (mx.qty.HasValue && mx.qty.Value > 1)
  819. {
  820. name_arr[0] = $"{mx.qty.Value.ToString("#,##0.0#")}个{mx.mtrlname}";
  821. }
  822. else
  823. {
  824. name_arr[0] = mx.mtrlname;
  825. }
  826. if (countDict.ContainsKey(mx.formulakind.Value))
  827. {
  828. chastr += countDict[mx.formulakind.Value];
  829. }
  830. // 添加包装信息
  831. interfaceList.Add(InserMattressInterfacePz("包装", chastr, 2, name_arr));
  832. }
  833. }
  834. // 压包数量
  835. interfaceList.Add(InserMattressInterfacePz("包装", "压包数量", 1, new string[] { $"{mattress.packqty.Value.ToString("#,##0.0#")}" }));
  836. // 包装说明
  837. interfaceList.Add(InserMattressInterfacePz("包装", "包装说明", 1, new string[] { "" }));
  838. // 压包说明
  839. if (mattress.packqty.HasValue && mattress.packqty.Value > 0) interfaceList.Add(InserMattressInterfacePz("包装", "压包说明", 1, new string[] { "" }));
  840. // 卷包说明
  841. if (mattress.diameter.HasValue && mattress.diameter.Value > 0) interfaceList.Add(InserMattressInterfacePz("包装", "卷包说明", 1, new string[] { "" }));
  842. }
  843. private void AutoSetFormulaType101Pz(u_mattress mattress, List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface> interfaceList)
  844. {
  845. var powerDict = new Dictionary<string, int[]>()
  846. {
  847. {"面裥绵",new int[] { 0, 40, 50, 60, 70 } },
  848. {"底裥绵",new int[] { 1, 41, 51, 61, 71 } },
  849. {"普通大侧",new int[] { 2, 42, 52, 62, 72 } }
  850. };
  851. var chastrDict = new Dictionary<string, string[]>()
  852. {
  853. {"面裥绵",new string[] { "内布套-面层裥棉", "内布套-面层裥棉裥棉图案" } },
  854. {"底裥绵",new string[] { "内布套-底层裥棉", "内布套-底层裥棉裥棉图案" } },
  855. {"普通大侧",new string[] { "内布套-大侧裥棉", "内布套-大侧裥棉裥棉图案" } }
  856. };
  857. foreach (var item in powerDict)
  858. {
  859. var name_arr = new string[5];
  860. foreach (var mx in mxlist)
  861. {
  862. SetFormulaTypeZeroPzName(mx, "内布套", item.Value, name_arr);
  863. }
  864. var sb = new StringBuilder();
  865. foreach (var name2 in name_arr)
  866. {
  867. sb.Append(name2);
  868. }
  869. if (sb.Length > 0)
  870. {
  871. interfaceList.Add(InserMattressInterfacePz("内布套", chastrDict[item.Key][0], 2, name_arr));
  872. interfaceList.Add(InserMattressInterfacePz("内布套", chastrDict[item.Key][1], 1, new string[] { "" }));
  873. }
  874. }
  875. // 内布套-围边边带 / 拉链
  876. foreach (var mx in mxlist)
  877. {
  878. if (mx.mtrlid > 0 && "内布套".Equals(mx.chastr) && mx.formulakind == 203)
  879. {
  880. interfaceList.Add(InserMattressInterfacePz("内布套", "内布套-围边边带", 2, new string[] { $"{mx.thickness.Value.ToString("#,##0.0#")}条共{mx.qty.Value.ToString("#,##0.0#")}米{mx.mtrlname}" }));
  881. }
  882. else if (mx.mtrlid > 0 && "内布套".Equals(mx.chastr) && mx.formulakind == 202)
  883. {
  884. interfaceList.Add(InserMattressInterfacePz("内布套", "内布套-拉链", 2, new string[] { $"{mx.thickness.Value.ToString("#,##0.0#")}条共{mx.qty.Value.ToString("#,##0.0#")}米{mx.mtrlname}" }));
  885. }
  886. }
  887. if (mattress.if_n_butao == 1)
  888. {
  889. interfaceList.Add(InserMattressInterfacePz("内布套", "内布套做法说明", 1, new string[] { $"内布套面层向大侧覆盖{mattress.s_cover_qty.Value.ToString("#,##0.0#")}CM、内布套大侧向底层覆盖{mattress.z_cover_qty.Value.ToString("#,##0.0#")}CM、内布套底层向大侧覆盖{mattress.x_cover_qty.Value.ToString("#,##0.0#")}CM" }));
  890. }
  891. }
  892. #endregion
  893. #region 导入清单方法
  894. public List<u_mattress_interface_qd> RefreshMattressInterfaceQdList(int mattressid)
  895. {
  896. var qdList = new List<u_mattress_interface_qd>();
  897. ImportMattressInterfaceQdList(mattressid, qdList);
  898. MattressInterfaceFindERPPrdPf(qdList,null);
  899. return qdList;
  900. }
  901. /// <summary>
  902. /// wf_fine_erp_prdpf
  903. /// </summary>
  904. /// <param name="qdList"></param>
  905. /// <param name="interfaceList"></param>
  906. public void MattressInterfaceFindERPPrdPf(List<u_mattress_interface_qd> qdList,List<u_mattress_interface> interfaceList)
  907. {
  908. var mtrlidList = new List<int>();
  909. foreach (var mx in qdList)
  910. {
  911. // 带出有设置 的erp_mtrlid
  912. if (mx.erp_mtrlid == 0 && mx.mtrlid != null && mx.mtrlid > 0)
  913. {
  914. var mtrldef = new u_mtrl_price() { mtrlid = mx.mtrlid };
  915. if (DbSqlHelper.SelectOne(cmd, mtrldef, "erp_mtrlid") == 1)
  916. {
  917. mx.erp_mtrlid = mtrldef.erp_mtrlid;
  918. }
  919. }
  920. //
  921. if (mx.erp_mtrlid > 0)
  922. {
  923. mtrlidList.Add(mx.erp_mtrlid.Value);
  924. }
  925. }
  926. var erpHelper = HelperBase.GetHelper<ERPHelper>(null);
  927. var parameters = new JObject();
  928. parameters.Add("mtrlids", JToken.FromObject(mtrlidList));
  929. var resultList = erpHelper.GetERPList<erp_mtrldef>("GetL1Mtrldef", parameters);
  930. if (resultList != null && resultList.Any())
  931. {
  932. foreach (var mx in qdList)
  933. {
  934. var result = resultList.FirstOrDefault(o => o.mtrlid == mx.erp_mtrlid);
  935. if (result != null)
  936. {
  937. mx.erp_mtrlcode = result.mtrlcode;
  938. mx.erp_mtrlname = result.mtrlname;
  939. mx.erp_mtrlmode = result.mtrlmode;
  940. mx.erp_unit = result.unit;
  941. mx.erp_mtrlengname = result.zxmtrlmode;
  942. }
  943. }
  944. }
  945. //更新 二级明细项目 需要产品配置列表,此部分由前端完成
  946. if (interfaceList != null && interfaceList.Any())
  947. {
  948. Dictionary<string, u_mattress_interface> interfaceDict = interfaceList.ToDictionary(mb => mb.bj_pzname, mb => mb);
  949. foreach (var mx in qdList)
  950. {
  951. if (interfaceDict.TryGetValue(mx.bj_pzname, out var mb))
  952. {
  953. mx.bj_pzname_mx_mx = mb.bj_namemx;
  954. if (mx.ss_rate == 0) mx.ss_rate = mb.ss_rate;
  955. if (mx.ls_rate == 0) mx.ls_rate = mb.ls_rate;
  956. }
  957. }
  958. }
  959. }
  960. /// <summary>
  961. /// 导入产品清单
  962. /// </summary>
  963. /// <param name="mattressid"></param>
  964. /// <exception cref="LJCommonException"></exception>
  965. public void ImportMattressInterfaceQdList(int mattressid, List<u_mattress_interface_qd> qdList)
  966. {
  967. if (mattressid <= 0)
  968. {
  969. throw new LJCommonException("床垫id有误");
  970. }
  971. var mattressHelper = GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = context.tokendata });
  972. var mattress = mattressHelper.GetMattress(mattressid);
  973. var mattress_type = new u_mattress_type() { mattresstypeid = mattress.mattresstypeid };
  974. DbSqlHelper.SelectOne(cmd, mattress_type, "typename");
  975. var mxlist = mattressHelper.GetMattressMxMtrl(mattressid, new List<string>() { "u_mattress_formula.formulatype IN (0,1,2,3,99,104)" });
  976. var mxlist_103 = mattressHelper.GetMattressMxMtrl(mattressid, new List<string>() { "u_mattress_formula.formulatype = 103" });
  977. var mxlist_101 = mattressHelper.GetMattressMxMtrl(mattressid, new List<string>() { "u_mattress_formula.formulatype = 101" });
  978. #region 面料类清单导入
  979. AutoSetFormulaTypeZeroPrdPf(mxlist, qdList);
  980. #endregion
  981. #region 垫层类清单导入
  982. AutoSetFormulaTypeOnePrdPf(mxlist, qdList);
  983. #endregion
  984. #region 辅料类清单导入
  985. AutoSetFormulaTypeTwoPrfPf(mxlist, qdList);
  986. #endregion
  987. #region 包装类清单导入
  988. AutoSetFormulaTypeThreePrdPf(mxlist, qdList);
  989. #endregion
  990. #region 内布套类清单导入
  991. AutoSetFormulaType101PrdPf(mxlist_103, qdList);
  992. #endregion
  993. // 最后初始化interfaceList的printid
  994. for (var i = 0; i < qdList.Count; i++)
  995. {
  996. qdList[i].printid = i + 1;
  997. }
  998. }
  999. /// <summary>
  1000. /// 初始化清单信息
  1001. /// </summary>
  1002. /// <param name="itemname"></param>
  1003. /// <param name="bj_pzname"></param>
  1004. /// <param name="inputtype"></param>
  1005. /// <param name="names"></param>
  1006. /// <returns></returns>
  1007. public u_mattress_interface_qd InserMattressInterfacePrdPf(string itemname, string bj_pzname, string namemx, int mtrlid, decimal useqty)
  1008. {
  1009. var mattress_interface_qd = new u_mattress_interface_qd()
  1010. {
  1011. itemname = itemname,
  1012. bj_pzname = bj_pzname,
  1013. bj_pzname_mx = namemx,
  1014. mtrlid = mtrlid,
  1015. useqty = useqty
  1016. };
  1017. return mattress_interface_qd;
  1018. }
  1019. public u_mattress_interface_qd InserMattressInterfacePrdPf(string itemname, string bj_pzname, string namemx)
  1020. {
  1021. var mattress_interface_qd = new u_mattress_interface_qd()
  1022. {
  1023. itemname = itemname,
  1024. bj_pzname = bj_pzname,
  1025. bj_pzname_mx = namemx
  1026. };
  1027. return mattress_interface_qd;
  1028. }
  1029. private void AutoSetFormulaTypeZeroPrdPf(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface_qd> qdList)
  1030. {
  1031. var powerDict = new Dictionary<string, int[]>()
  1032. {
  1033. {"面裥绵",new int[] { 0, 40, 50, 60, 70, 80 } },
  1034. {"底裥绵",new int[] { 1, 41, 51, 61, 71, 81 } },
  1035. {"顶布裥棉1",new int[] { 0, 40, 50, 60, 70, 80 } },
  1036. {"顶布裥棉2",new int[] { 0, 40, 50, 60, 70, 80 } },
  1037. {"普通大侧",new int[] { 2, 42, 52, 62, 72, 82 } },
  1038. {"上下拼侧1",new int[] { 2, 42, 52, 62, 72, 82 } },
  1039. {"上下拼侧2",new int[] { 2, 42, 52, 62, 72, 82 } },
  1040. {"上下拼侧3",new int[] { 2, 42, 52, 62, 72, 82 } },
  1041. {"左右拼侧1",new int[] { 2, 42, 52, 62, 72, 82 } },
  1042. {"左右拼侧2",new int[] { 2, 42, 52, 62, 72, 82 } },
  1043. {"左右拼侧3",new int[] { 2, 42, 52, 62, 72, 82 } },
  1044. {"小侧1_EMPTY",new int[] { 3, 43, 53, 63, 73, 83 } },
  1045. {"小侧1",new int[] { 3, 43, 53, 63, 73, 83 } },
  1046. {"小侧1-上下拼侧1",new int[] { 3, 43, 53, 63, 73, 83 } },
  1047. {"小侧1-上下拼侧2",new int[] { 3, 43, 53, 63, 73, 83 } },
  1048. {"小侧1-上下拼侧3",new int[] { 3, 43, 53, 63, 73, 83 } },
  1049. {"小侧2",new int[] { 3, 43, 53, 63, 73, 83 } },
  1050. {"小侧3",new int[] { 3, 43, 53, 63, 73, 83 } },
  1051. {"V侧1_EMPTY",new int[] { 4, 44, 54, 64, 74, 84 } },
  1052. {"V侧1",new int[] { 4, 44, 54, 64, 74, 84 } }
  1053. };
  1054. var chastrArrDict = new Dictionary<string, string[]>()
  1055. {
  1056. {"面裥绵",new string[] { "裥面", "面层裥棉", "面层裥面说明" } },
  1057. {"底裥绵",new string[] { "裥底", "底层裥棉", "底层裥棉说明" } },
  1058. {"顶布裥棉1",new string[] { "顶布裥棉", "顶布裥棉1" } },
  1059. {"顶布裥棉2",new string[] { "顶布裥棉", "顶布裥棉2" } },
  1060. {"普通大侧",new string[] { "大侧", "大侧裥棉"} },
  1061. {"上下拼侧1",new string[] {"大侧", "大侧-上下拼侧1"} },
  1062. {"上下拼侧2",new string[] { "大侧", "大侧-上下拼侧2" } },
  1063. {"上下拼侧3",new string[] { "大侧", "大侧-上下拼侧3" } },
  1064. {"左右拼侧1",new string[] { "大侧", "大侧-左右拼侧1"} },
  1065. {"左右拼侧2",new string[] { "大侧", "大侧-左右拼侧2"} },
  1066. {"左右拼侧3",new string[] { "大侧", "大侧-左右拼侧3" ,"大侧说明" } },
  1067. {"小侧1_EMPTY",new string[] { "小侧", "小侧1裥棉" } },
  1068. {"小侧1",new string[] { "小侧", "小侧1裥棉"} },
  1069. {"小侧1-上下拼侧1",new string[] { "小侧", "小侧1-上下拼侧1裥棉" } },
  1070. {"小侧1-上下拼侧2",new string[] { "小侧", "小侧1-上下拼侧2裥棉" } },
  1071. {"小侧1-上下拼侧3",new string[] { "小侧", "小侧1-上下拼侧3裥棉" } },
  1072. {"小侧2",new string[] { "小侧", "小侧2裥棉", "小侧2裥棉图案" } },
  1073. {"小侧3",new string[] { "小侧", "小侧3裥棉", "小侧3裥棉图案", "小侧说明" } },
  1074. {"V侧1_EMPTY",new string[] { "V侧", "V侧1裥棉", "V侧1裥棉图案" } },
  1075. {"V侧1",new string[] { "V侧", "V侧1裥棉", "V侧1裥棉图案" } },
  1076. {"V侧2",new string[] { "V侧", "V侧2裥棉", "V侧2裥棉图案" } },
  1077. {"V侧3",new string[] { "V侧", "V侧3裥棉", "V侧3裥棉图案", "V侧说明" } }
  1078. };
  1079. var extreDict = new HashSet<string>() { "小侧", "V侧" };
  1080. var jianmianList = mxlist.Where(t => t.formulatype == 0).ToList();
  1081. var isEnter = false;
  1082. #region wf_import_qingdan_prdpf
  1083. foreach (var item in powerDict)
  1084. {
  1085. // 保证清单列表类别一致,从面裥绵 -> V侧3
  1086. foreach (var mx in jianmianList)
  1087. {
  1088. if (mx.mtrlid > 0 && (item.Key.Equals(mx.chastr) || item.Key.Contains("_EMPTY")) && item.Value.Contains(mx.formulakind.Value))
  1089. {
  1090. if (mx.formulakind == 0 || mx.formulakind == 1 || mx.formulakind == 2 || mx.formulakind == 3)
  1091. {
  1092. qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], chastrArrDict[item.Key][1], "布料", mx.mtrlid.Value, mx.useqty.Value));
  1093. }
  1094. if (mx.formulakind == 40 || mx.formulakind == 41 || mx.formulakind == 42 || mx.formulakind == 43)
  1095. {
  1096. qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], chastrArrDict[item.Key][1], "喷胶棉", mx.mtrlid.Value, mx.useqty.Value));
  1097. }
  1098. if (mx.formulakind == 50 || mx.formulakind == 51 || mx.formulakind == 52 || mx.formulakind == 53)
  1099. {
  1100. qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], chastrArrDict[item.Key][1], "裥面海绵", mx.mtrlid.Value, mx.useqty.Value));
  1101. }
  1102. if (mx.formulakind == 60 || mx.formulakind == 61 || mx.formulakind == 62 || mx.formulakind == 63)
  1103. {
  1104. qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], chastrArrDict[item.Key][1], "无纺布", mx.mtrlid.Value, mx.useqty.Value));
  1105. }
  1106. }
  1107. }
  1108. if(item.Key.Contains("小侧3") || item.Key.Contains("V侧3"))
  1109. {
  1110. var list = qdList.FindAll(t => extreDict.Contains(t.itemname)).ToList();
  1111. if(list.Any())
  1112. {
  1113. foreach (var name in chastrArrDict[item.Key])
  1114. {
  1115. if (name.Contains("说明"))
  1116. {
  1117. qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], name, ""));
  1118. }
  1119. }
  1120. }
  1121. } else
  1122. {
  1123. foreach (var name in chastrArrDict[item.Key])
  1124. {
  1125. if (name.Contains("说明"))
  1126. {
  1127. qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], name, ""));
  1128. }
  1129. }
  1130. }
  1131. }
  1132. #endregion
  1133. #region wf_import_qingdan_next 面料部分
  1134. // 按照 formulakind 分组
  1135. var grouped = jianmianList
  1136. .Where(t => t.formulakind >= 5 && t.formulakind <= 10)
  1137. .GroupBy(t => t.formulakind);
  1138. // 需要处理的组的名称与编号映射
  1139. var groupNames = new Dictionary<int, string>
  1140. {
  1141. { 5, "拉手" },
  1142. { 6, "刺绣" },
  1143. { 7, "大侧压压布" },
  1144. { 8, "大侧压边带" },
  1145. { 9, "大侧压织带" },
  1146. { 10, "大侧压上下压线" }
  1147. };
  1148. // 处理每一组
  1149. foreach (var group in grouped)
  1150. {
  1151. var formulakind = group.Key.Value;
  1152. var name = groupNames.ContainsKey(formulakind) ? groupNames[formulakind] : "未知组";
  1153. foreach (var mx in group)
  1154. {
  1155. if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
  1156. {
  1157. qdList.Add(InserMattressInterfacePrdPf("拉手刺绣及其他工艺",$"{name}{group.ToList().IndexOf(mx) + 1}","",
  1158. mx.mtrlid.Value,
  1159. mx.useqty.Value
  1160. ));
  1161. }
  1162. }
  1163. }
  1164. // 统一添加固定项
  1165. qdList.Add(InserMattressInterfacePrdPf("拉手刺绣及其他工艺", "拉手刺绣", ""));
  1166. qdList.Add(InserMattressInterfacePrdPf("拉手刺绣及其他工艺", "拉手无纺布", ""));
  1167. qdList.Add(InserMattressInterfacePrdPf("拉手刺绣及其他工艺", "侧刺绣做法", ""));
  1168. #endregion
  1169. }
  1170. private void AutoSetFormulaTypeOnePrdPf(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface_qd> qdList)
  1171. {
  1172. var diancengList = mxlist.Where(t => t.formulatype == 1).ToList();
  1173. var kindDict = new Dictionary<int, string>()
  1174. {
  1175. { 32,"垫层" },
  1176. { 12,"顶布" },
  1177. { 13,"毡类" },
  1178. { 14,"打底无纺布" },
  1179. { 29,"网面布料" },
  1180. { 999,"床网" }
  1181. };
  1182. var chastrSet = new HashSet<string>() { "大侧", "小侧1", "小侧2", "小侧3", "V侧1", "V侧2", "V侧3" };
  1183. var countDict = new Dictionary<string, int>();
  1184. foreach (var cha in chastrSet)
  1185. {
  1186. foreach (var kind in kindDict)
  1187. {
  1188. countDict.Add($"{cha}-{kind.Value}", 0);
  1189. }
  1190. }
  1191. foreach (var mx in diancengList)
  1192. {
  1193. var key = $"{mx.chastr}-{kindDict[mx.formulakind.Value]}";
  1194. if (mx.mtrlid > 0 && new int[] { 32, 12, 13, 14, 29 }.Contains(mx.formulakind.Value))
  1195. {
  1196. this.ProcessWangMianBLPrdPf(mx, qdList, mx.chastr, kindDict[mx.formulakind.Value], ++countDict[key]);
  1197. }
  1198. if (mx.formulakind == 999)
  1199. {
  1200. this.ProcessChuangWangPrdPf(mx, qdList, mx.chastr, ++countDict[key]);
  1201. }
  1202. }
  1203. // 顶布裥面说明
  1204. qdList.Add(InserMattressInterfacePrdPf("顶布裥棉", "顶布裥面说明1", ""));
  1205. qdList.Add(InserMattressInterfacePrdPf("顶布裥棉", "顶布裥面说明2", ""));
  1206. }
  1207. /// <summary>
  1208. /// 床网
  1209. /// </summary>
  1210. /// <param name="mx"></param>
  1211. /// <param name="interfaceList"></param>
  1212. /// <param name="chastr"></param>
  1213. /// <param name="count"></param>
  1214. private void ProcessChuangWangPrdPf(u_mattress_mx_mtrl mx, List<u_mattress_interface_qd> qdList, string chastr, int count)
  1215. {
  1216. var namepz = string.Empty;
  1217. int bednetid = 0;
  1218. cmd.CommandText = @"SELECT u_bednetmx.bednet_height,u_bednetmx.bednetid
  1219. FROM u_bednetmx
  1220. INNER JOIN (
  1221. SELECT mtrlid
  1222. FROM u_mattress_mx_mtrl
  1223. INNER JOIN u_mattress_formula ON u_mattress_formula.formulaid = u_mattress_mx_mtrl.formulaid
  1224. WHERE u_mattress_formula.formulakind = 99
  1225. AND u_mattress_mx_mtrl.mattressid = @mattressid
  1226. AND u_mattress_mx_mtrl.mtrlid > 0
  1227. ) v_mattress_mx_mtrl ON u_bednetmx.bednetid = v_mattress_mx_mtrl.mtrlid";
  1228. cmd.Parameters.Clear();
  1229. cmd.Parameters.AddWithValue("@mattressid", mx.mattressid);
  1230. using (var reader = cmd.ExecuteReader())
  1231. {
  1232. while (reader.Read())
  1233. {
  1234. decimal height = Convert.ToDecimal(reader["bednet_height"]);
  1235. if (height == mx.thickness) bednetid = Convert.ToInt32(reader["bednetid"]);
  1236. }
  1237. }
  1238. if (bednetid > 0)
  1239. {
  1240. // 获取床网清单
  1241. var bednetList = new List<u_bednetmx>();
  1242. if (bednetList.Any())
  1243. {
  1244. var bednetHelper = HelperBase.GetHelper<BedNetHelper>(cmd);
  1245. var bednetQdList = bednetHelper.GetBedNetQingDan(bednetid);
  1246. if (bednetQdList.Any())
  1247. {
  1248. namepz = bednetQdList[0].pznamemx;
  1249. }
  1250. }
  1251. }
  1252. qdList.Add(InserMattressInterfacePrdPf("垫层", $"{chastr}-床网{count}", namepz, mx.mtrlid.Value, mx.useqty.Value));
  1253. // 海绵条*4 2
  1254. qdList.Add(InserMattressInterfacePrdPf("垫层", "海绵条1", ""));
  1255. qdList.Add(InserMattressInterfacePrdPf("垫层", "海绵条2", ""));
  1256. qdList.Add(InserMattressInterfacePrdPf("垫层", "海绵条3", ""));
  1257. qdList.Add(InserMattressInterfacePrdPf("垫层", "海绵条4", ""));
  1258. }
  1259. /// <summary>
  1260. /// 网面布料 / 打底无纺布 / 毡类 / 顶布 / 垫层
  1261. /// </summary>
  1262. /// <param name="mx"></param>
  1263. /// <param name="interfaceList"></param>
  1264. /// <param name="chastr"></param>
  1265. /// <param name="count"></param>
  1266. private void ProcessWangMianBLPrdPf(u_mattress_mx_mtrl mx, List<u_mattress_interface_qd> qdList, string chastr, string typename, int count)
  1267. {
  1268. var mtrlname_temp = mx.mtrlname;
  1269. if ((!mx.mtrlname.Contains("分") && mx.thickness > 0) || ("垫层".Equals(typename)))
  1270. {
  1271. mtrlname_temp = $"{mx.thickness.Value.ToString("#,##0.0#")}分{mx.mtrlname}";
  1272. }
  1273. qdList.Add(InserMattressInterfacePrdPf("垫层", $"{chastr}-{typename}{count}", "",mx.mtrlid.Value,mx.useqty.Value));
  1274. }
  1275. private void AutoSetFormulaTypeTwoPrfPf(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface_qd> qdList)
  1276. {
  1277. var fuliaoList = mxlist.Where(t => t.formulatype == 2).ToList();
  1278. var nameSet = new HashSet<string>(new string[] {
  1279. "保用卡", "采购小标", "打钮钮扣", "打印小标", "合格证", "画纸", "开箱说明+开箱刀", "吊标", "客供标",
  1280. "空白牛皮纸包角", "空白珍珠包角", "气钮","说明书","斜标","正标","织唛","织唛斜标"
  1281. });
  1282. var extraSet = new HashSet<string>(new string[] { "保用卡", "采购小标", "打钮钮扣", "打印小标", "合格证", "画纸", "开箱说明+开箱刀", "吊标", "客供标",
  1283. "空白牛皮纸包角", "空白珍珠包角", "气钮","说明书","斜标","正标","织唛","织唛斜标","角网+拉链","开箱刀+开箱说明" });
  1284. var specialSet = new HashSet<string>(new string[] { "打钮钮扣", "气钮" });
  1285. foreach (var mx in fuliaoList)
  1286. {
  1287. if (mx.mtrlid > 0)
  1288. {
  1289. int cnt = Convert.ToInt32(Math.Abs(mx.qty.Value));
  1290. // 处理特殊辅料
  1291. if (specialSet.Contains(mx.mtrlname))
  1292. {
  1293. qdList.Add(InserMattressInterfacePrdPf("辅料", $"{mx.mtrlname}", "", mx.mtrlid.Value, mx.useqty.Value));
  1294. continue; // 跳过后续的处理
  1295. }
  1296. // 处理其他辅料
  1297. if (nameSet.Contains(mx.mtrlname))
  1298. {
  1299. for (int i = 1; i <= cnt; i++)
  1300. {
  1301. // 添加辅料接口
  1302. qdList.Add(InserMattressInterfacePrdPf("辅料", $"{mx.mtrlname}{i}", "",mx.mtrlid.Value,mx.useqty.Value));
  1303. }
  1304. } else if(mx.formulakind == 15 && !extraSet.Contains(mx.mtrlname))
  1305. {
  1306. for (int i = 1; i <= cnt; i++)
  1307. {
  1308. // 添加辅料接口
  1309. qdList.Add(InserMattressInterfacePrdPf("辅料", $"{mx.mtrlname}{i}", "", mx.mtrlid.Value, mx.useqty.Value));
  1310. // 如果是额外的辅料,添加位置接口
  1311. qdList.Add(InserMattressInterfacePrdPf("辅料", $"{mx.mtrlname}{i}位置", "", mx.mtrlid.Value, mx.useqty.Value));
  1312. }
  1313. }
  1314. }
  1315. }
  1316. }
  1317. private void AutoSetFormulaTypeThreePrdPf(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface_qd> qdList)
  1318. {
  1319. // 筛选 formulatype 为 3 的物料
  1320. var bzList = mxlist.Where(t => t.formulatype == 3).ToList();
  1321. var chastrDict = new Dictionary<int, string>
  1322. {
  1323. {16, "PE袋"},
  1324. {17, "外层PE"},
  1325. {18, "PVC"},
  1326. {19, "卷包包装"},
  1327. {20, "牛皮纸袋"},
  1328. {21, "蓝色PE护角"},
  1329. {22, "无纺布袋"},
  1330. {23, "牛皮袋护角"},
  1331. {24, "编织袋"},
  1332. {27, "拉手脚轮"},
  1333. {201, "无纺布护角"}
  1334. };
  1335. var countDict = new Dictionary<int, int>
  1336. {
  1337. {16, 0}
  1338. };
  1339. foreach (var mx in bzList)
  1340. {
  1341. if (mx.mtrlid > 0 && chastrDict.TryGetValue(mx.formulakind.GetValueOrDefault(), out var chastr))
  1342. {
  1343. var name_arr = new string[1];
  1344. if (mx.qty.HasValue && mx.qty.Value > 1)
  1345. {
  1346. name_arr[0] = $"{mx.qty.Value.ToString("#,##0.0#")}个{mx.mtrlname}";
  1347. }
  1348. else
  1349. {
  1350. name_arr[0] = mx.mtrlname;
  1351. }
  1352. if (countDict.ContainsKey(mx.formulakind.Value))
  1353. {
  1354. chastr += countDict[mx.formulakind.Value];
  1355. }
  1356. // 添加包装信息
  1357. qdList.Add(InserMattressInterfacePrdPf("包装", chastr,"",mx.mtrlid.Value,mx.useqty.Value));
  1358. }
  1359. }
  1360. // 包装说明
  1361. qdList.Add(InserMattressInterfacePrdPf("包装", "包装说明", ""));
  1362. // 车位说明
  1363. qdList.Add(InserMattressInterfacePrdPf("车位说明", "车位说明", ""));
  1364. }
  1365. private void AutoSetFormulaType101PrdPf(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface_qd> qdList)
  1366. {
  1367. var powerDict = new Dictionary<string, int[]>()
  1368. {
  1369. {"面裥绵",new int[] { 0, 40, 50, 60, 70,80 } },
  1370. {"底裥绵",new int[] { 1, 41, 51, 61, 71 } },
  1371. {"普通大侧",new int[] { 2, 42, 52, 62, 72 } }
  1372. };
  1373. var chastrDict = new Dictionary<string, string[]>()
  1374. {
  1375. {"面裥绵",new string[] { "内布套-面层裥棉", "内布套-面层裥棉裥棉图案" } },
  1376. {"底裥绵",new string[] { "内布套-底层裥棉", "内布套-底层裥棉裥棉图案" } },
  1377. {"普通大侧",new string[] { "内布套-大侧裥棉", "内布套-大侧裥棉裥棉图案" } }
  1378. };
  1379. foreach (var item in powerDict)
  1380. {
  1381. var name_arr = new string[5];
  1382. foreach (var mx in mxlist)
  1383. {
  1384. if (mx.mtrlid > 0 && (item.Key.Equals(mx.chastr) || item.Key.Contains("_EMPTY")) && item.Value.Contains(mx.formulakind.Value))
  1385. {
  1386. if (mx.formulakind == 0 || mx.formulakind == 1 || mx.formulakind == 2 || mx.formulakind == 3)
  1387. {
  1388. qdList.Add(InserMattressInterfacePrdPf(chastrDict[item.Key][0], chastrDict[item.Key][1], "布料", mx.mtrlid.Value, mx.useqty.Value));
  1389. }
  1390. if (mx.formulakind == 40 || mx.formulakind == 41 || mx.formulakind == 42 || mx.formulakind == 43)
  1391. {
  1392. qdList.Add(InserMattressInterfacePrdPf(chastrDict[item.Key][0], chastrDict[item.Key][1], "喷胶棉", mx.mtrlid.Value, mx.useqty.Value));
  1393. }
  1394. if (mx.formulakind == 50 || mx.formulakind == 51 || mx.formulakind == 52 || mx.formulakind == 53)
  1395. {
  1396. qdList.Add(InserMattressInterfacePrdPf(chastrDict[item.Key][0], chastrDict[item.Key][1], "裥面海绵", mx.mtrlid.Value, mx.useqty.Value));
  1397. }
  1398. if (mx.formulakind == 60 || mx.formulakind == 61 || mx.formulakind == 62 || mx.formulakind == 63)
  1399. {
  1400. qdList.Add(InserMattressInterfacePrdPf(chastrDict[item.Key][0], chastrDict[item.Key][1], "无纺布", mx.mtrlid.Value, mx.useqty.Value));
  1401. }
  1402. }
  1403. }
  1404. }
  1405. // 内布套-围边边带 / 拉链
  1406. foreach (var mx in mxlist)
  1407. {
  1408. if (mx.mtrlid > 0 && "内布套".Equals(mx.chastr) && mx.formulakind == 203)
  1409. {
  1410. qdList.Add(InserMattressInterfacePrdPf("内布套", "内布套-围边边带", "围边",mx.mtrlid.Value,mx.useqty.Value));
  1411. }
  1412. else if (mx.mtrlid > 0 && "内布套".Equals(mx.chastr) && mx.formulakind == 202)
  1413. {
  1414. qdList.Add(InserMattressInterfacePrdPf("内布套", "内布套-拉链", "拉链", mx.mtrlid.Value, mx.useqty.Value));
  1415. }
  1416. }
  1417. }
  1418. #endregion
  1419. #region 通用方法
  1420. /// <summary>
  1421. /// 用于 字符串 + 字符串格式
  1422. /// </summary>
  1423. /// <param name="currentString"></param>
  1424. /// <param name="newPart"></param>
  1425. /// <returns></returns>
  1426. private string AppendToString(string currentString, string newPart)
  1427. {
  1428. if (string.IsNullOrEmpty(currentString))
  1429. {
  1430. return newPart;
  1431. }
  1432. else
  1433. {
  1434. return currentString + " + " + newPart;
  1435. }
  1436. }
  1437. /// <summary>
  1438. /// 数量分割字符串
  1439. /// </summary>
  1440. /// <param name="name"></param>
  1441. /// <param name="qty"></param>
  1442. /// <returns></returns>
  1443. private string SplitNameCount(string name, int qty)
  1444. {
  1445. if (qty <= 1) return name;
  1446. var result = name;
  1447. result = AppendToString(result, SplitNameCount(name, --qty));
  1448. return result;
  1449. }
  1450. #endregion
  1451. #region 全局变量
  1452. // 储存顶布裥棉数据
  1453. private string[,] DingBuLianMian = new string[4,5];
  1454. private enum PackType
  1455. {
  1456. 压包 = 0,
  1457. 卷包,
  1458. 国内
  1459. }
  1460. #endregion
  1461. }
  1462. }