InterfaceHelper.cs 75 KB

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