InterfaceHelper.cs 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619
  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. foreach (var mx in qdList)
  931. {
  932. if (resultList != null && resultList.Any())
  933. {
  934. foreach (var result in resultList)
  935. {
  936. mx.erp_mtrlcode = result.mtrlcode;
  937. mx.erp_mtrlname = result.mtrlname;
  938. mx.erp_mtrlmode = result.mtrlmode;
  939. mx.erp_unit = result.unit;
  940. mx.erp_mtrlengname = result.zxmtrlmode;
  941. }
  942. }
  943. }
  944. //更新 二级明细项目 需要产品配置列表,此部分由前端完成
  945. if (interfaceList != null && interfaceList.Any())
  946. {
  947. Dictionary<string, u_mattress_interface> interfaceDict = interfaceList.ToDictionary(mb => mb.bj_pzname, mb => mb);
  948. foreach (var mx in qdList)
  949. {
  950. if (interfaceDict.TryGetValue(mx.bj_pzname, out var mb))
  951. {
  952. mx.bj_pzname_mx_mx = mb.bj_namemx;
  953. if (mx.ss_rate == 0) mx.ss_rate = mb.ss_rate;
  954. if (mx.ls_rate == 0) mx.ls_rate = mb.ls_rate;
  955. }
  956. }
  957. }
  958. }
  959. /// <summary>
  960. /// 导入产品清单
  961. /// </summary>
  962. /// <param name="mattressid"></param>
  963. /// <exception cref="LJCommonException"></exception>
  964. public void ImportMattressInterfaceQdList(int mattressid, List<u_mattress_interface_qd> qdList)
  965. {
  966. if (mattressid <= 0)
  967. {
  968. throw new LJCommonException("床垫id有误");
  969. }
  970. var mattressHelper = GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = context.tokendata });
  971. var mattress = mattressHelper.GetMattress(mattressid);
  972. var mattress_type = new u_mattress_type() { mattresstypeid = mattress.mattresstypeid };
  973. DbSqlHelper.SelectOne(cmd, mattress_type, "typename");
  974. var mxlist = mattressHelper.GetMattressMxMtrl(mattressid, new List<string>() { "u_mattress_formula.formulatype IN (0,1,2,3,99,104)" });
  975. var mxlist_103 = mattressHelper.GetMattressMxMtrl(mattressid, new List<string>() { "u_mattress_formula.formulatype = 103" });
  976. var mxlist_101 = mattressHelper.GetMattressMxMtrl(mattressid, new List<string>() { "u_mattress_formula.formulatype = 101" });
  977. #region 面料类清单导入
  978. AutoSetFormulaTypeZeroPrdPf(mxlist, qdList);
  979. #endregion
  980. #region 垫层类清单导入
  981. AutoSetFormulaTypeOnePrdPf(mxlist, qdList);
  982. #endregion
  983. #region 辅料类清单导入
  984. AutoSetFormulaTypeTwoPrfPf(mxlist, qdList);
  985. #endregion
  986. #region 包装类清单导入
  987. AutoSetFormulaTypeThreePrdPf(mxlist, qdList);
  988. #endregion
  989. #region 内布套类清单导入
  990. AutoSetFormulaType101PrdPf(mxlist_103, qdList);
  991. #endregion
  992. // 最后初始化interfaceList的printid
  993. for (var i = 0; i < qdList.Count; i++)
  994. {
  995. qdList[i].printid = i + 1;
  996. }
  997. }
  998. /// <summary>
  999. /// 初始化清单信息
  1000. /// </summary>
  1001. /// <param name="itemname"></param>
  1002. /// <param name="bj_pzname"></param>
  1003. /// <param name="inputtype"></param>
  1004. /// <param name="names"></param>
  1005. /// <returns></returns>
  1006. public u_mattress_interface_qd InserMattressInterfacePrdPf(string itemname, string bj_pzname, string namemx, int mtrlid, decimal useqty)
  1007. {
  1008. var mattress_interface_qd = new u_mattress_interface_qd()
  1009. {
  1010. itemname = itemname,
  1011. bj_pzname = bj_pzname,
  1012. bj_pzname_mx = namemx,
  1013. mtrlid = mtrlid,
  1014. useqty = useqty
  1015. };
  1016. return mattress_interface_qd;
  1017. }
  1018. public u_mattress_interface_qd InserMattressInterfacePrdPf(string itemname, string bj_pzname, string namemx)
  1019. {
  1020. var mattress_interface_qd = new u_mattress_interface_qd()
  1021. {
  1022. itemname = itemname,
  1023. bj_pzname = bj_pzname,
  1024. bj_pzname_mx = namemx
  1025. };
  1026. return mattress_interface_qd;
  1027. }
  1028. private void AutoSetFormulaTypeZeroPrdPf(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface_qd> qdList)
  1029. {
  1030. var powerDict = new Dictionary<string, int[]>()
  1031. {
  1032. {"面裥绵",new int[] { 0, 40, 50, 60, 70, 80 } },
  1033. {"底裥绵",new int[] { 1, 41, 51, 61, 71, 81 } },
  1034. {"顶布裥棉1",new int[] { 0, 40, 50, 60, 70, 80 } },
  1035. {"顶布裥棉2",new int[] { 0, 40, 50, 60, 70, 80 } },
  1036. {"普通大侧",new int[] { 2, 42, 52, 62, 72, 82 } },
  1037. {"上下拼侧1",new int[] { 2, 42, 52, 62, 72, 82 } },
  1038. {"上下拼侧2",new int[] { 2, 42, 52, 62, 72, 82 } },
  1039. {"上下拼侧3",new int[] { 2, 42, 52, 62, 72, 82 } },
  1040. {"左右拼侧1",new int[] { 2, 42, 52, 62, 72, 82 } },
  1041. {"左右拼侧2",new int[] { 2, 42, 52, 62, 72, 82 } },
  1042. {"左右拼侧3",new int[] { 2, 42, 52, 62, 72, 82 } },
  1043. {"小侧1_EMPTY",new int[] { 3, 43, 53, 63, 73, 83 } },
  1044. {"小侧1",new int[] { 3, 43, 53, 63, 73, 83 } },
  1045. {"小侧1-上下拼侧1",new int[] { 3, 43, 53, 63, 73, 83 } },
  1046. {"小侧1-上下拼侧2",new int[] { 3, 43, 53, 63, 73, 83 } },
  1047. {"小侧1-上下拼侧3",new int[] { 3, 43, 53, 63, 73, 83 } },
  1048. {"小侧2",new int[] { 3, 43, 53, 63, 73, 83 } },
  1049. {"小侧3",new int[] { 3, 43, 53, 63, 73, 83 } },
  1050. {"V侧1_EMPTY",new int[] { 4, 44, 54, 64, 74, 84 } },
  1051. {"V侧1",new int[] { 4, 44, 54, 64, 74, 84 } }
  1052. };
  1053. var chastrArrDict = new Dictionary<string, string[]>()
  1054. {
  1055. {"面裥绵",new string[] { "裥面", "面层裥棉", "面层裥面说明" } },
  1056. {"底裥绵",new string[] { "裥底", "底层裥棉", "底层裥棉说明" } },
  1057. {"顶布裥棉1",new string[] { "顶布裥棉", "顶布裥棉1" } },
  1058. {"顶布裥棉2",new string[] { "顶布裥棉", "顶布裥棉2" } },
  1059. {"普通大侧",new string[] { "大侧", "大侧裥棉"} },
  1060. {"上下拼侧1",new string[] {"大侧", "大侧-上下拼侧1"} },
  1061. {"上下拼侧2",new string[] { "大侧", "大侧-上下拼侧2" } },
  1062. {"上下拼侧3",new string[] { "大侧", "大侧-上下拼侧3" } },
  1063. {"左右拼侧1",new string[] { "大侧", "大侧-左右拼侧1"} },
  1064. {"左右拼侧2",new string[] { "大侧", "大侧-左右拼侧2"} },
  1065. {"左右拼侧3",new string[] { "大侧", "大侧-左右拼侧3" ,"大侧说明" } },
  1066. {"小侧1_EMPTY",new string[] { "小侧", "小侧1裥棉" } },
  1067. {"小侧1",new string[] { "小侧", "小侧1裥棉"} },
  1068. {"小侧1-上下拼侧1",new string[] { "小侧", "小侧1-上下拼侧1裥棉" } },
  1069. {"小侧1-上下拼侧2",new string[] { "小侧", "小侧1-上下拼侧2裥棉" } },
  1070. {"小侧1-上下拼侧3",new string[] { "小侧", "小侧1-上下拼侧3裥棉" } },
  1071. {"小侧2",new string[] { "小侧", "小侧2裥棉", "小侧2裥棉图案" } },
  1072. {"小侧3",new string[] { "小侧", "小侧3裥棉", "小侧3裥棉图案", "小侧说明" } },
  1073. {"V侧1_EMPTY",new string[] { "V侧", "V侧1裥棉", "V侧1裥棉图案" } },
  1074. {"V侧1",new string[] { "V侧", "V侧1裥棉", "V侧1裥棉图案" } },
  1075. {"V侧2",new string[] { "V侧", "V侧2裥棉", "V侧2裥棉图案" } },
  1076. {"V侧3",new string[] { "V侧", "V侧3裥棉", "V侧3裥棉图案", "V侧说明" } }
  1077. };
  1078. var extreDict = new HashSet<string>() { "小侧", "V侧" };
  1079. var jianmianList = mxlist.Where(t => t.formulatype == 0).ToList();
  1080. var isEnter = false;
  1081. #region wf_import_qingdan_prdpf
  1082. foreach (var item in powerDict)
  1083. {
  1084. // 保证清单列表类别一致,从面裥绵 -> V侧3
  1085. foreach (var mx in jianmianList)
  1086. {
  1087. if (mx.mtrlid > 0 && (item.Key.Equals(mx.chastr) || item.Key.Contains("_EMPTY")) && item.Value.Contains(mx.formulakind.Value))
  1088. {
  1089. if (mx.formulakind == 0 || mx.formulakind == 1 || mx.formulakind == 2 || mx.formulakind == 3)
  1090. {
  1091. qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], chastrArrDict[item.Key][1], "布料", mx.mtrlid.Value, mx.useqty.Value));
  1092. }
  1093. if (mx.formulakind == 40 || mx.formulakind == 41 || mx.formulakind == 42 || mx.formulakind == 43)
  1094. {
  1095. qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], chastrArrDict[item.Key][1], "喷胶棉", mx.mtrlid.Value, mx.useqty.Value));
  1096. }
  1097. if (mx.formulakind == 50 || mx.formulakind == 51 || mx.formulakind == 52 || mx.formulakind == 53)
  1098. {
  1099. qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], chastrArrDict[item.Key][1], "裥面海绵", mx.mtrlid.Value, mx.useqty.Value));
  1100. }
  1101. if (mx.formulakind == 60 || mx.formulakind == 61 || mx.formulakind == 62 || mx.formulakind == 63)
  1102. {
  1103. qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], chastrArrDict[item.Key][1], "无纺布", mx.mtrlid.Value, mx.useqty.Value));
  1104. }
  1105. }
  1106. }
  1107. if(item.Key.Contains("小侧3") || item.Key.Contains("V侧3"))
  1108. {
  1109. var list = qdList.FindAll(t => extreDict.Contains(t.itemname)).ToList();
  1110. if(list.Any())
  1111. {
  1112. foreach (var name in chastrArrDict[item.Key])
  1113. {
  1114. if (name.Contains("说明"))
  1115. {
  1116. qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], name, ""));
  1117. }
  1118. }
  1119. }
  1120. } else
  1121. {
  1122. foreach (var name in chastrArrDict[item.Key])
  1123. {
  1124. if (name.Contains("说明"))
  1125. {
  1126. qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], name, ""));
  1127. }
  1128. }
  1129. }
  1130. }
  1131. #endregion
  1132. #region wf_import_qingdan_next 面料部分
  1133. // 按照 formulakind 分组
  1134. var grouped = jianmianList
  1135. .Where(t => t.formulakind >= 5 && t.formulakind <= 10)
  1136. .GroupBy(t => t.formulakind);
  1137. // 需要处理的组的名称与编号映射
  1138. var groupNames = new Dictionary<int, string>
  1139. {
  1140. { 5, "拉手" },
  1141. { 6, "刺绣" },
  1142. { 7, "大侧压压布" },
  1143. { 8, "大侧压边带" },
  1144. { 9, "大侧压织带" },
  1145. { 10, "大侧压上下压线" }
  1146. };
  1147. // 处理每一组
  1148. foreach (var group in grouped)
  1149. {
  1150. var formulakind = group.Key.Value;
  1151. var name = groupNames.ContainsKey(formulakind) ? groupNames[formulakind] : "未知组";
  1152. foreach (var mx in group)
  1153. {
  1154. if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
  1155. {
  1156. qdList.Add(InserMattressInterfacePrdPf("拉手刺绣及其他工艺",$"{name}{group.ToList().IndexOf(mx) + 1}","",
  1157. mx.mtrlid.Value,
  1158. mx.useqty.Value
  1159. ));
  1160. }
  1161. }
  1162. }
  1163. // 统一添加固定项
  1164. qdList.Add(InserMattressInterfacePrdPf("拉手刺绣及其他工艺", "拉手刺绣", ""));
  1165. qdList.Add(InserMattressInterfacePrdPf("拉手刺绣及其他工艺", "拉手无纺布", ""));
  1166. qdList.Add(InserMattressInterfacePrdPf("拉手刺绣及其他工艺", "侧刺绣做法", ""));
  1167. #endregion
  1168. }
  1169. private void AutoSetFormulaTypeOnePrdPf(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface_qd> qdList)
  1170. {
  1171. var diancengList = mxlist.Where(t => t.formulatype == 1).ToList();
  1172. var kindDict = new Dictionary<int, string>()
  1173. {
  1174. { 32,"垫层" },
  1175. { 12,"顶布" },
  1176. { 13,"毡类" },
  1177. { 14,"打底无纺布" },
  1178. { 29,"网面布料" },
  1179. { 999,"床网" }
  1180. };
  1181. var chastrSet = new HashSet<string>() { "大侧", "小侧1", "小侧2", "小侧3", "V侧1", "V侧2", "V侧3" };
  1182. var countDict = new Dictionary<string, int>();
  1183. foreach (var cha in chastrSet)
  1184. {
  1185. foreach (var kind in kindDict)
  1186. {
  1187. countDict.Add($"{cha}-{kind.Value}", 0);
  1188. }
  1189. }
  1190. foreach (var mx in diancengList)
  1191. {
  1192. var key = $"{mx.chastr}-{kindDict[mx.formulakind.Value]}";
  1193. if (mx.mtrlid > 0 && new int[] { 32, 12, 13, 14, 29 }.Contains(mx.formulakind.Value))
  1194. {
  1195. this.ProcessWangMianBLPrdPf(mx, qdList, mx.chastr, kindDict[mx.formulakind.Value], ++countDict[key]);
  1196. }
  1197. if (mx.formulakind == 999)
  1198. {
  1199. this.ProcessChuangWangPrdPf(mx, qdList, mx.chastr, ++countDict[key]);
  1200. }
  1201. }
  1202. // 顶布裥面说明
  1203. qdList.Add(InserMattressInterfacePrdPf("顶布裥棉", "顶布裥面说明1", ""));
  1204. qdList.Add(InserMattressInterfacePrdPf("顶布裥棉", "顶布裥面说明2", ""));
  1205. }
  1206. /// <summary>
  1207. /// 床网
  1208. /// </summary>
  1209. /// <param name="mx"></param>
  1210. /// <param name="interfaceList"></param>
  1211. /// <param name="chastr"></param>
  1212. /// <param name="count"></param>
  1213. private void ProcessChuangWangPrdPf(u_mattress_mx_mtrl mx, List<u_mattress_interface_qd> qdList, string chastr, int count)
  1214. {
  1215. var namepz = string.Empty;
  1216. int bednetid = 0;
  1217. cmd.CommandText = @"SELECT u_bednetmx.bednet_height,u_bednetmx.bednetid
  1218. FROM u_bednetmx
  1219. INNER JOIN (
  1220. SELECT mtrlid
  1221. FROM u_mattress_mx_mtrl
  1222. INNER JOIN u_mattress_formula ON u_mattress_formula.formulaid = u_mattress_mx_mtrl.formulaid
  1223. WHERE u_mattress_formula.formulakind = 99
  1224. AND u_mattress_mx_mtrl.mattressid = @mattressid
  1225. AND u_mattress_mx_mtrl.mtrlid > 0
  1226. ) v_mattress_mx_mtrl ON u_bednetmx.bednetid = v_mattress_mx_mtrl.mtrlid";
  1227. cmd.Parameters.Clear();
  1228. cmd.Parameters.AddWithValue("@mattressid", mx.mattressid);
  1229. using (var reader = cmd.ExecuteReader())
  1230. {
  1231. while (reader.Read())
  1232. {
  1233. decimal height = Convert.ToDecimal(reader["bednet_height"]);
  1234. if (height == mx.thickness) bednetid = Convert.ToInt32(reader["bednetid"]);
  1235. }
  1236. }
  1237. if (bednetid > 0)
  1238. {
  1239. // 获取床网清单
  1240. var bednetList = new List<u_bednetmx>();
  1241. if (bednetList.Any())
  1242. {
  1243. var bednetHelper = HelperBase.GetHelper<BedNetHelper>(cmd);
  1244. var bednetQdList = bednetHelper.GetBedNetQingDan(bednetid);
  1245. if (bednetQdList.Any())
  1246. {
  1247. namepz = bednetQdList[0].pznamemx;
  1248. }
  1249. }
  1250. }
  1251. qdList.Add(InserMattressInterfacePrdPf("垫层", $"{chastr}-床网{count}", namepz, mx.mtrlid.Value, mx.useqty.Value));
  1252. // 海绵条*4 2
  1253. qdList.Add(InserMattressInterfacePrdPf("垫层", "海绵条1", ""));
  1254. qdList.Add(InserMattressInterfacePrdPf("垫层", "海绵条2", ""));
  1255. qdList.Add(InserMattressInterfacePrdPf("垫层", "海绵条3", ""));
  1256. qdList.Add(InserMattressInterfacePrdPf("垫层", "海绵条4", ""));
  1257. }
  1258. /// <summary>
  1259. /// 网面布料 / 打底无纺布 / 毡类 / 顶布 / 垫层
  1260. /// </summary>
  1261. /// <param name="mx"></param>
  1262. /// <param name="interfaceList"></param>
  1263. /// <param name="chastr"></param>
  1264. /// <param name="count"></param>
  1265. private void ProcessWangMianBLPrdPf(u_mattress_mx_mtrl mx, List<u_mattress_interface_qd> qdList, string chastr, string typename, int count)
  1266. {
  1267. var mtrlname_temp = mx.mtrlname;
  1268. if ((!mx.mtrlname.Contains("分") && mx.thickness > 0) || ("垫层".Equals(typename)))
  1269. {
  1270. mtrlname_temp = $"{mx.thickness.Value.ToString("#,##0.0#")}分{mx.mtrlname}";
  1271. }
  1272. qdList.Add(InserMattressInterfacePrdPf("垫层", $"{chastr}-{typename}{count}", "",mx.mtrlid.Value,mx.useqty.Value));
  1273. }
  1274. private void AutoSetFormulaTypeTwoPrfPf(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface_qd> qdList)
  1275. {
  1276. var fuliaoList = mxlist.Where(t => t.formulatype == 2).ToList();
  1277. var nameSet = new HashSet<string>(new string[] {
  1278. "保用卡", "采购小标", "打钮钮扣", "打印小标", "合格证", "画纸", "开箱说明+开箱刀", "吊标", "客供标",
  1279. "空白牛皮纸包角", "空白珍珠包角", "气钮","说明书","斜标","正标","织唛","织唛斜标"
  1280. });
  1281. var extraSet = new HashSet<string>(new string[] { "保用卡", "采购小标", "打钮钮扣", "打印小标", "合格证", "画纸", "开箱说明+开箱刀", "吊标", "客供标",
  1282. "空白牛皮纸包角", "空白珍珠包角", "气钮","说明书","斜标","正标","织唛","织唛斜标","角网+拉链","开箱刀+开箱说明" });
  1283. var specialSet = new HashSet<string>(new string[] { "打钮钮扣", "气钮" });
  1284. foreach (var mx in fuliaoList)
  1285. {
  1286. if (mx.mtrlid > 0)
  1287. {
  1288. int cnt = Convert.ToInt32(Math.Abs(mx.qty.Value));
  1289. // 处理特殊辅料
  1290. if (specialSet.Contains(mx.mtrlname))
  1291. {
  1292. qdList.Add(InserMattressInterfacePrdPf("辅料", $"{mx.mtrlname}", "", mx.mtrlid.Value, mx.useqty.Value));
  1293. continue; // 跳过后续的处理
  1294. }
  1295. // 处理其他辅料
  1296. if (nameSet.Contains(mx.mtrlname))
  1297. {
  1298. for (int i = 1; i <= cnt; i++)
  1299. {
  1300. // 添加辅料接口
  1301. qdList.Add(InserMattressInterfacePrdPf("辅料", $"{mx.mtrlname}{i}", "",mx.mtrlid.Value,mx.useqty.Value));
  1302. }
  1303. } else if(mx.formulakind == 15 && !extraSet.Contains(mx.mtrlname))
  1304. {
  1305. for (int i = 1; i <= cnt; i++)
  1306. {
  1307. // 添加辅料接口
  1308. qdList.Add(InserMattressInterfacePrdPf("辅料", $"{mx.mtrlname}{i}", "", mx.mtrlid.Value, mx.useqty.Value));
  1309. // 如果是额外的辅料,添加位置接口
  1310. qdList.Add(InserMattressInterfacePrdPf("辅料", $"{mx.mtrlname}{i}位置", "", mx.mtrlid.Value, mx.useqty.Value));
  1311. }
  1312. }
  1313. }
  1314. }
  1315. }
  1316. private void AutoSetFormulaTypeThreePrdPf(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface_qd> qdList)
  1317. {
  1318. // 筛选 formulatype 为 3 的物料
  1319. var bzList = mxlist.Where(t => t.formulatype == 3).ToList();
  1320. var chastrDict = new Dictionary<int, string>
  1321. {
  1322. {16, "PE袋"},
  1323. {17, "外层PE"},
  1324. {18, "PVC"},
  1325. {19, "卷包包装"},
  1326. {20, "牛皮纸袋"},
  1327. {21, "蓝色PE护角"},
  1328. {22, "无纺布袋"},
  1329. {23, "牛皮袋护角"},
  1330. {24, "编织袋"},
  1331. {27, "拉手脚轮"},
  1332. {201, "无纺布护角"}
  1333. };
  1334. var countDict = new Dictionary<int, int>
  1335. {
  1336. {16, 0}
  1337. };
  1338. foreach (var mx in bzList)
  1339. {
  1340. if (mx.mtrlid > 0 && chastrDict.TryGetValue(mx.formulakind.GetValueOrDefault(), out var chastr))
  1341. {
  1342. var name_arr = new string[1];
  1343. if (mx.qty.HasValue && mx.qty.Value > 1)
  1344. {
  1345. name_arr[0] = $"{mx.qty.Value.ToString("#,##0.0#")}个{mx.mtrlname}";
  1346. }
  1347. else
  1348. {
  1349. name_arr[0] = mx.mtrlname;
  1350. }
  1351. if (countDict.ContainsKey(mx.formulakind.Value))
  1352. {
  1353. chastr += countDict[mx.formulakind.Value];
  1354. }
  1355. // 添加包装信息
  1356. qdList.Add(InserMattressInterfacePrdPf("包装", chastr,"",mx.mtrlid.Value,mx.useqty.Value));
  1357. }
  1358. }
  1359. // 包装说明
  1360. qdList.Add(InserMattressInterfacePrdPf("包装", "包装说明", ""));
  1361. // 车位说明
  1362. qdList.Add(InserMattressInterfacePrdPf("车位说明", "车位说明", ""));
  1363. }
  1364. private void AutoSetFormulaType101PrdPf(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface_qd> qdList)
  1365. {
  1366. var powerDict = new Dictionary<string, int[]>()
  1367. {
  1368. {"面裥绵",new int[] { 0, 40, 50, 60, 70,80 } },
  1369. {"底裥绵",new int[] { 1, 41, 51, 61, 71 } },
  1370. {"普通大侧",new int[] { 2, 42, 52, 62, 72 } }
  1371. };
  1372. var chastrDict = new Dictionary<string, string[]>()
  1373. {
  1374. {"面裥绵",new string[] { "内布套-面层裥棉", "内布套-面层裥棉裥棉图案" } },
  1375. {"底裥绵",new string[] { "内布套-底层裥棉", "内布套-底层裥棉裥棉图案" } },
  1376. {"普通大侧",new string[] { "内布套-大侧裥棉", "内布套-大侧裥棉裥棉图案" } }
  1377. };
  1378. foreach (var item in powerDict)
  1379. {
  1380. var name_arr = new string[5];
  1381. foreach (var mx in mxlist)
  1382. {
  1383. if (mx.mtrlid > 0 && (item.Key.Equals(mx.chastr) || item.Key.Contains("_EMPTY")) && item.Value.Contains(mx.formulakind.Value))
  1384. {
  1385. if (mx.formulakind == 0 || mx.formulakind == 1 || mx.formulakind == 2 || mx.formulakind == 3)
  1386. {
  1387. qdList.Add(InserMattressInterfacePrdPf(chastrDict[item.Key][0], chastrDict[item.Key][1], "布料", mx.mtrlid.Value, mx.useqty.Value));
  1388. }
  1389. if (mx.formulakind == 40 || mx.formulakind == 41 || mx.formulakind == 42 || mx.formulakind == 43)
  1390. {
  1391. qdList.Add(InserMattressInterfacePrdPf(chastrDict[item.Key][0], chastrDict[item.Key][1], "喷胶棉", mx.mtrlid.Value, mx.useqty.Value));
  1392. }
  1393. if (mx.formulakind == 50 || mx.formulakind == 51 || mx.formulakind == 52 || mx.formulakind == 53)
  1394. {
  1395. qdList.Add(InserMattressInterfacePrdPf(chastrDict[item.Key][0], chastrDict[item.Key][1], "裥面海绵", mx.mtrlid.Value, mx.useqty.Value));
  1396. }
  1397. if (mx.formulakind == 60 || mx.formulakind == 61 || mx.formulakind == 62 || mx.formulakind == 63)
  1398. {
  1399. qdList.Add(InserMattressInterfacePrdPf(chastrDict[item.Key][0], chastrDict[item.Key][1], "无纺布", mx.mtrlid.Value, mx.useqty.Value));
  1400. }
  1401. }
  1402. }
  1403. }
  1404. // 内布套-围边边带 / 拉链
  1405. foreach (var mx in mxlist)
  1406. {
  1407. if (mx.mtrlid > 0 && "内布套".Equals(mx.chastr) && mx.formulakind == 203)
  1408. {
  1409. qdList.Add(InserMattressInterfacePrdPf("内布套", "内布套-围边边带", "围边",mx.mtrlid.Value,mx.useqty.Value));
  1410. }
  1411. else if (mx.mtrlid > 0 && "内布套".Equals(mx.chastr) && mx.formulakind == 202)
  1412. {
  1413. qdList.Add(InserMattressInterfacePrdPf("内布套", "内布套-拉链", "拉链", mx.mtrlid.Value, mx.useqty.Value));
  1414. }
  1415. }
  1416. }
  1417. #endregion
  1418. #region 通用方法
  1419. /// <summary>
  1420. /// 用于 字符串 + 字符串格式
  1421. /// </summary>
  1422. /// <param name="currentString"></param>
  1423. /// <param name="newPart"></param>
  1424. /// <returns></returns>
  1425. private string AppendToString(string currentString, string newPart)
  1426. {
  1427. if (string.IsNullOrEmpty(currentString))
  1428. {
  1429. return newPart;
  1430. }
  1431. else
  1432. {
  1433. return currentString + " + " + newPart;
  1434. }
  1435. }
  1436. /// <summary>
  1437. /// 数量分割字符串
  1438. /// </summary>
  1439. /// <param name="name"></param>
  1440. /// <param name="qty"></param>
  1441. /// <returns></returns>
  1442. private string SplitNameCount(string name, int qty)
  1443. {
  1444. if (qty <= 1) return name;
  1445. var result = name;
  1446. result = AppendToString(result, SplitNameCount(name, --qty));
  1447. return result;
  1448. }
  1449. #endregion
  1450. #region 全局变量
  1451. // 储存顶布裥棉数据
  1452. private string[,] DingBuLianMian = new string[4,5];
  1453. private enum PackType
  1454. {
  1455. 压包 = 0,
  1456. 卷包,
  1457. 国内
  1458. }
  1459. #endregion
  1460. }
  1461. }