ExtJobService.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. using Business.Core.Utilities;
  2. using Business.EntityFrameworkCore;
  3. using Bussiness.Model.Ext;
  4. using Bussiness.Model.MES.IC;
  5. using Microsoft.EntityFrameworkCore;
  6. using Microsoft.Extensions.Hosting;
  7. using NLog;
  8. using SixLabors.ImageSharp;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading;
  14. using System.Threading.Tasks;
  15. using System.Xml.Linq;
  16. using Volo.Abp.Application.Services;
  17. using Volo.Abp.Domain.Repositories;
  18. namespace Business.Quartz
  19. {
  20. //处理Ext数据库表
  21. public class ExtJobService: ApplicationService
  22. {
  23. SnowFlake help = new SnowFlake();
  24. private IRepository<in_kd_material, long> _kd_material;
  25. private IRepository<ic_item, long> _ic_item;
  26. private IRepository<ic_itemTest, long> _ic_itemTest;
  27. private IRepository<ic_item_ie, long> _ic_item_ie;
  28. private IRepository<ic_item_ieTest, long> _ic_item_ieTest;
  29. private IRepository<ic_item_inventory, long> _ic_item_inventory;
  30. private IRepository<ic_item_pur, long> _ic_item_pur;
  31. private IRepository<ic_item_purTest, long> _ic_item_purTest;
  32. private IRepository<ic_item_stock, long> _ic_item_stock;
  33. private IRepository<ic_plan, long> _ic_plan;
  34. private IRepository<ic_planTest, long> _ic_planTest;
  35. private IRepository<ic_check, long> _ic_check;
  36. private IRepository<ic_factory_details, long> _ic_factory_details;
  37. private IRepository<ic_factory_detailsTest, long> _ic_factory_detailsTest;
  38. private IRepository<in_kd_bom, long> _kd_bom;
  39. private IRepository<ic_bom, long> _ic_bom;
  40. private IRepository<ic_bom_child, long> _ic_bom_child;
  41. private IRepository<ic_substitute, long> _ic_substitute;
  42. private IRepository<ic_substitute_all, long> _ic_substitute_all;
  43. private IRepository<ic_substitute_all_dtl, long> _ic_substitute_all_dtl;
  44. private IRepository<ext_xref, long> _ext_xref;
  45. private IRepository<ext_xrefTest, long> _ext_xrefTest;
  46. private readonly BusinessDbContext _businessDbContext;
  47. private readonly BusinessExtDbContext _businessExtDbContext;
  48. public ExtJobService(
  49. IRepository<in_kd_material, long> kd_material,
  50. IRepository<ic_item, long> ic_item,
  51. IRepository<ic_itemTest, long> ic_itemTest,
  52. IRepository<ic_item_ie, long> ic_item_ie,
  53. IRepository<ic_item_ieTest, long> ic_item_ieTest,
  54. IRepository<ic_item_inventory, long> ic_item_inventory,
  55. IRepository<ic_item_pur, long> ic_item_pur,
  56. IRepository<ic_item_purTest, long> ic_item_purTest,
  57. IRepository<ic_item_stock, long> ic_item_stock,
  58. IRepository<ic_plan, long> ic_plan,
  59. IRepository<ic_planTest, long> ic_planTest,
  60. IRepository<ic_check, long> ic_check,
  61. IRepository<ic_factory_details, long> ic_factory_details,
  62. IRepository<ic_factory_detailsTest, long> ic_factory_detailsTest,
  63. IRepository<in_kd_bom, long> kd_bom,
  64. IRepository<ic_bom, long> ic_bom,
  65. IRepository<ic_bom_child, long> ic_bom_child,
  66. IRepository<ic_substitute, long> ic_substitute,
  67. IRepository<ic_substitute_all, long> ic_substitute_all,
  68. IRepository<ic_substitute_all_dtl, long> ic_substitute_all_dtl,
  69. IRepository<ext_xref, long> ext_xref,
  70. IRepository<ext_xrefTest, long> ext_xrefTest,
  71. BusinessDbContext businessDbContext,
  72. BusinessExtDbContext businessExtDbContext
  73. )
  74. {
  75. _kd_material= kd_material;
  76. _ic_item= ic_item;
  77. _ic_itemTest = ic_itemTest;
  78. _ic_item_ie = ic_item_ie;
  79. _ic_item_ieTest = ic_item_ieTest;
  80. _ic_item_inventory = ic_item_inventory;
  81. _ic_item_pur= ic_item_pur;
  82. _ic_item_purTest = ic_item_purTest;
  83. _ic_item_stock = ic_item_stock;
  84. _ic_plan= ic_plan;
  85. _ic_planTest = ic_planTest;
  86. _ic_check = ic_check;
  87. _ic_factory_details= ic_factory_details;
  88. _ic_factory_detailsTest = ic_factory_detailsTest;
  89. _kd_bom = kd_bom;
  90. _ic_bom= ic_bom;
  91. _ic_bom_child= ic_bom_child;
  92. _ic_substitute= ic_substitute;
  93. _ic_substitute_all= ic_substitute_all;
  94. _ic_substitute_all_dtl= ic_substitute_all_dtl;
  95. _ext_xref= ext_xref;
  96. _ext_xrefTest = ext_xrefTest;
  97. _businessDbContext = businessDbContext;
  98. _businessExtDbContext = businessExtDbContext;
  99. }
  100. /// <summary>
  101. /// 处理物料
  102. /// </summary>
  103. public async void DoExt()
  104. {
  105. await DoMaterial();
  106. //DoBom();
  107. }
  108. /// <summary>
  109. /// 处理物料
  110. /// </summary>
  111. public async Task DoMaterial()
  112. {
  113. var extMaterials=_kd_material.GetListAsync();
  114. var ic_items = _ic_itemTest.GetListAsync(p => p.factory_id == 10101 && p.org_id == 101 && p.tenant_id == 101);
  115. var ic_factory_detailss = _ic_factory_detailsTest.GetListAsync(p => p.factory_id == 10101 && p.org_id == 101 && p.tenant_id == 101);
  116. var ic_item_ies = _ic_item_ieTest.GetListAsync(p => p.factory_id == 10101 && p.org_id == 101 && p.tenant_id == 101);
  117. var ic_item_purs = _ic_item_purTest.GetListAsync(p => p.factory_id == 10101 && p.org_id == 101 && p.tenant_id == 101);
  118. var ic_plans = _ic_planTest.GetListAsync(p => p.factory_id == 10101 && p.org_id == 101 && p.tenant_id == 101);
  119. List<ic_itemTest> ic_itemListAdd = new List<ic_itemTest>();
  120. List<ic_itemTest> ic_itemListUpdate = new List<ic_itemTest>();
  121. List<ic_factory_detailsTest> ic_factory_detailsListAdd = new List<ic_factory_detailsTest>();
  122. List<ic_factory_detailsTest> ic_factory_detailsListUpdate = new List<ic_factory_detailsTest>();
  123. List<ic_item_ieTest> ic_item_ieListAdd = new List<ic_item_ieTest>();
  124. List<ic_item_ieTest> ic_item_ieListUpdate = new List<ic_item_ieTest>();
  125. List<ic_item_purTest> ic_item_purListAdd = new List<ic_item_purTest>();
  126. List<ic_item_purTest> ic_item_purListUpdate = new List<ic_item_purTest>();
  127. List<ic_planTest> ic_planListAdd = new List<ic_planTest>();
  128. List<ic_planTest> ic_planListUpdate = new List<ic_planTest>();
  129. List<ext_xrefTest> ext_xrefList = new List<ext_xrefTest>();
  130. if (extMaterials != null)
  131. {
  132. extMaterials.Result.ForEach(ext =>
  133. {
  134. if (ic_items != null && ic_items.Result.Exists(a => a.number == ext.FNumber))
  135. {
  136. var ic_item = ic_items.Result.FirstOrDefault(a => a.number == ext.FNumber);
  137. if (ic_item != null)
  138. {
  139. ic_item.number = ext.FNumber;
  140. ic_item.name = ext.FName_2052;
  141. ic_item.model = ext.FSpecification_2052;
  142. ic_item.full_name = ext.FDescription_2052;
  143. ic_item.fms_number = ext.FOldNumber;
  144. //0.配置类 1. 2.委外加工 3.外购 4.虚拟件
  145. ic_item.erp_cls = ext.FErpClsID == "配置类" ? 0 : ext.FErpClsID == "自制" ? 1 : ext.FErpClsID == "委外" ? 2 : ext.FErpClsID == "外购" ? 3 : ext.FErpClsID == "虚拟" ? 4 : ext.FErpClsID == "费用" ? 5 : ext.FErpClsID == "服务" ? 6 : -1;
  146. ic_item.source = ext.FDataSource;
  147. ic_item.iskeyitem = ext.FIsKitting == "是" ? 1 : 0;
  148. ic_item.gross_weight = ext.FGROSSWEIGHT;
  149. ic_item.net_weight = ext.FNETWEIGHT;
  150. ic_item.maund = ext.FWEIGHTUNITID_Name;
  151. ic_item.cubic_measure = ext.FVOLUMEUNITID_Name;
  152. ic_item.length = ext.FLENGTH;
  153. ic_item.width = ext.FWIDTH;
  154. ic_item.height = ext.FHEIGHT;
  155. ic_item.size = ext.FVOLUME;
  156. ic_item.allowpur = ext.FIsPurchase == "是" ? 1 : 0;
  157. ic_item.allowsale = ext.FIsSale == "是" ? 1 : 0;
  158. ic_item.allowmanu = ext.FIsProduce == "是" ? 1 : 0;
  159. ic_item.allowout = ext.FIsSubContract == "是" ? 1 : 0;
  160. ic_item.allowbatch = ext.F_SFJLPCH == "是" ? 1 : 0;
  161. ic_itemListUpdate.Add(ic_item);
  162. ext_xrefList.Add(new ext_xrefTest
  163. {
  164. dop_table_name = "ic_item",
  165. dop_id = ic_item.Id,
  166. dop_col1_name = "number",
  167. dop_col1_value = ic_item.number,
  168. other_sys_name = "kd",
  169. other_table_name = "in_kd_material",
  170. other_id = ext.Id,
  171. other_col1_name = "FNumber",
  172. other_col1_value = ext.FNumber
  173. });
  174. var ic_factory_detail = ic_factory_detailss.Result.FirstOrDefault(a => a.icitem_id == ic_item.Id);
  175. if (ic_factory_detail != null)
  176. {
  177. ic_factory_detail.product_line = ext.F_CPX_Name;
  178. ic_factory_detail.minpackqty = ext.FIncreaseQty;
  179. ic_factory_detailsListUpdate.Add(ic_factory_detail);
  180. }
  181. var ic_item_ie = ic_item_ies.Result.FirstOrDefault(a => a.icitem_id == ic_item.Id);
  182. if (ic_item_ie != null)
  183. {
  184. ic_item_ie.isbackflush = ext.FIsBatchManage == "是" ? 1 : 0;
  185. ic_item_ieListUpdate.Add(ic_item_ie);
  186. }
  187. var ic_item_pur = ic_item_purs.Result.FirstOrDefault(a => a.icitem_id == ic_item.Id);
  188. if (ic_item_pur != null)
  189. {
  190. ic_item_pur.icitem_name = ic_item.name;
  191. ic_item_pur.purchgroup = ext.FPurchaseGroupId_Name;
  192. ic_item_pur.purcher = ext.FPurchaserId_Name;
  193. ic_item_pur.purchase_unit = ext.FPurchaseUnitId_Name;
  194. ic_item_purListUpdate.Add(ic_item_pur);
  195. }
  196. var ic_plan = ic_plans.Result.FirstOrDefault(a => a.icitem_id == ic_item.Id);
  197. if (ic_plan != null)
  198. {
  199. ic_plan.icitem_name = ic_item.name;
  200. ic_plan.planner_name = ext.FPurchaseGroupId_Name;
  201. ic_plan.fix_leadtime = ext.FFixLeadTime;
  202. ic_plan.plan_trategy = ext.FPlanningStrategy == "MRP" ? 1 : 0;
  203. ic_plan.order_trategy = ext.FOrderPolicy == "LFL(批对批)" ? 1 : 0;
  204. ic_plan.order_inter_val = ext.FOrderIntervalTime;
  205. ic_plan.lead_time = ext.FVarLeadTime;
  206. ic_plan.bat_change_economy = ext.FVarLeadTimeLotSize;
  207. ic_plan.order_point = ext.FReOrderGood;
  208. ic_plan.secinv = ext.FPlanSafeStockQty;
  209. ic_planListUpdate.Add(ic_plan);
  210. }
  211. }
  212. }
  213. else
  214. {
  215. ic_itemTest item = new ic_itemTest(help.NextId());
  216. item.number = ext.FNumber;
  217. item.name = ext.FName_2052;
  218. item.model = ext.FSpecification_2052;
  219. item.full_name = ext.FDescription_2052;
  220. item.fms_number = ext.FOldNumber;
  221. //0.配置类 1. 2.委外加工 3.外购 4.虚拟件
  222. item.erp_cls = ext.FErpClsID == "配置类" ? 0 : ext.FErpClsID == "自制" ? 1 : ext.FErpClsID == "委外" ? 2 : ext.FErpClsID == "外购" ? 3 : ext.FErpClsID == "虚拟" ? 4 : ext.FErpClsID == "费用" ? 5 : ext.FErpClsID == "服务" ? 6 : -1;
  223. item.source = ext.FDataSource;
  224. item.iskeyitem = ext.FIsKitting == "是" ? 1 : 0;
  225. item.gross_weight = ext.FGROSSWEIGHT;
  226. item.net_weight = ext.FNETWEIGHT;
  227. item.maund = ext.FWEIGHTUNITID_Name;
  228. item.cubic_measure = ext.FVOLUMEUNITID_Name;
  229. item.length = ext.FLENGTH;
  230. item.width = ext.FWIDTH;
  231. item.height = ext.FHEIGHT;
  232. item.size = ext.FVOLUME;
  233. item.allowpur = ext.FIsPurchase == "是" ? 1 : 0;
  234. item.allowsale = ext.FIsSale == "是" ? 1 : 0;
  235. item.allowmanu = ext.FIsProduce == "是" ? 1 : 0;
  236. item.allowout = ext.FIsSubContract == "是" ? 1 : 0;
  237. item.allowbatch = ext.F_SFJLPCH == "是" ? 1 : 0;
  238. item.tenant_id = 101;//TODO
  239. item.factory_id = 10101;//TODO
  240. item.org_id = 101;//TODO
  241. item.IsDeleted = false;//TODO
  242. item.is_equipment = 0;
  243. item.item_level = 0;
  244. item.hb_level = 0;
  245. item.matatt = 0;
  246. item.picktype = 0;
  247. item.enable_warning = 0;
  248. ic_itemListAdd.Add(item);
  249. ext_xrefList.Add(new ext_xrefTest
  250. {
  251. dop_table_name = "ic_item",
  252. dop_id = item.Id,
  253. dop_col1_name = "number",
  254. dop_col1_value = item.number,
  255. other_sys_name = "kd",
  256. other_table_name = "in_kd_material",
  257. other_id = ext.Id,
  258. other_col1_name = "FNumber",
  259. other_col1_value = ext.FNumber
  260. });
  261. ic_factory_detailsListAdd.Add(new ic_factory_detailsTest(help.NextId())
  262. {
  263. icitem_id = item.Id,
  264. icitem_name = ext.FName_2052,
  265. tenant_id = 101,//TODO
  266. factory_id = 10101,////TODO
  267. org_id = 101,//TODO
  268. IsDeleted = false,//TODO
  269. pick_type = 0,
  270. stock_time = 0,
  271. batch_manager = 0,
  272. days_per = 0,
  273. default_chkloc = 0,
  274. default_chksp = 0,
  275. default_loc = 0,
  276. default_sp = 0,
  277. product_line = ext.F_CPX_Name,
  278. production_leadtime = 0,
  279. stock_leadtime = 0,
  280. transportation_leadtime = 0,
  281. order_leadtime = 0,
  282. minpackqty = ext.FIncreaseQty,
  283. minorderqty = 0
  284. });
  285. ic_item_ieListAdd.Add(new ic_item_ieTest(help.NextId())
  286. {
  287. icitem_id = item.Id,
  288. isbackflush = ext.FIsBatchManage == "是" ? 1 : 0,
  289. put_integer = 0,//TODO
  290. tenant_id = 101,//TODO
  291. factory_id = 10101,////TODO
  292. org_id = 101,//TODO
  293. IsDeleted = false,//TODO
  294. });
  295. ic_item_purListAdd.Add(new ic_item_purTest(help.NextId())
  296. {
  297. icitem_id = item.Id,
  298. icitem_name = item.name,
  299. currency_type = ext.FCurrencyId_Name == "人民币" ? 1 : 0,//TODO
  300. tenant_id = 101,//TODO
  301. factory_id = 10101,////TODO
  302. org_id = 101,//TODO
  303. IsDeleted = false,//TODO
  304. supplier_id = 0,
  305. purchgroup = ext.FPurchaseGroupId_Name,
  306. purcher = ext.FPurchaserId_Name,
  307. purchase_unit = ext.FPurchaseUnitId_Name
  308. });
  309. ic_planListAdd.Add(new ic_planTest(help.NextId())
  310. {
  311. icitem_id = item.Id,
  312. icitem_name = item.name,
  313. planner_name = ext.FPurchaseGroupId_Name,
  314. fix_leadtime = ext.FFixLeadTime,
  315. plan_trategy = ext.FPlanningStrategy == "MRP" ? 1 : 0,
  316. order_trategy = ext.FOrderPolicy == "LFL(批对批)" ? 1 : 0,
  317. order_inter_val = ext.FOrderIntervalTime,
  318. lead_time = ext.FVarLeadTime,
  319. bat_change_economy = ext.FVarLeadTimeLotSize,
  320. order_point = ext.FReOrderGood,
  321. secinv = ext.FPlanSafeStockQty,
  322. tenant_id = 101,//TODO
  323. factory_id = 10101,////TODO
  324. org_id = 101,//TODO
  325. IsDeleted = false,//TODO
  326. });
  327. }
  328. });
  329. if (ic_itemListAdd.Count > 0)
  330. {
  331. await _ic_itemTest.InsertManyAsync(ic_itemListAdd);
  332. //_businessDbContext.ic_itemTest.AddRange(ic_itemListAdd);
  333. //await _businessDbContext.ic_itemTest.BatchInsertIntoAsync(_businessDbContext.ic_itemTest);
  334. }
  335. if (ic_itemListUpdate.Count > 0)
  336. {
  337. await _ic_itemTest.UpdateManyAsync(ic_itemListUpdate);
  338. }
  339. if (ic_factory_detailsListAdd.Count > 0)
  340. {
  341. await _ic_factory_detailsTest.InsertManyAsync(ic_factory_detailsListAdd);
  342. //_businessDbContext.ic_factory_detailsTest.AddRange(ic_factory_detailsListAdd);
  343. //await _businessDbContext.ic_factory_detailsTest.BatchInsertIntoAsync(_businessDbContext.ic_factory_detailsTest);
  344. }
  345. if (ic_factory_detailsListUpdate.Count > 0)
  346. {
  347. await _ic_factory_detailsTest.UpdateManyAsync(ic_factory_detailsListUpdate);
  348. }
  349. if (ic_item_ieListAdd.Count > 0)
  350. {
  351. await _ic_item_ieTest.InsertManyAsync(ic_item_ieListAdd);
  352. //_businessDbContext.ic_item_ieTest.AddRange(ic_item_ieListAdd);
  353. //await _businessDbContext.ic_item_ieTest.BatchInsertIntoAsync(_businessDbContext.ic_item_ieTest);
  354. }
  355. if (ic_item_ieListUpdate.Count > 0)
  356. {
  357. await _ic_item_ieTest.UpdateManyAsync(ic_item_ieListUpdate);
  358. }
  359. if (ic_item_purListAdd.Count > 0)
  360. {
  361. await _ic_item_purTest.InsertManyAsync(ic_item_purListAdd);
  362. //_businessDbContext.ic_item_purTest.AddRange(ic_item_purListAdd);
  363. //await _businessDbContext.ic_item_purTest.BatchInsertIntoAsync(_businessDbContext.ic_item_purTest);
  364. }
  365. if (ic_item_purListUpdate.Count > 0)
  366. {
  367. await _ic_item_purTest.UpdateManyAsync(ic_item_purListUpdate);
  368. }
  369. if (ic_planListAdd.Count > 0)
  370. {
  371. await _ic_planTest.InsertManyAsync(ic_planListAdd);
  372. //_businessDbContext.ic_planTest.AddRange(ic_planListAdd);
  373. //await _businessDbContext.ic_planTest.BatchInsertIntoAsync(_businessDbContext.ic_planTest);
  374. }
  375. if (ic_planListUpdate.Count > 0)
  376. {
  377. await _ic_planTest.UpdateManyAsync(ic_planListUpdate);
  378. }
  379. if (ext_xrefList.Count > 0)
  380. {
  381. await _ext_xrefTest.InsertManyAsync(ext_xrefList);
  382. //_businessExtDbContext.ext_xrefTest.AddRange(ext_xrefList);
  383. //await _businessExtDbContext.ext_xrefTest.BatchInsertIntoAsync(_businessExtDbContext.ext_xrefTest);
  384. }
  385. }
  386. //var ic_items = _ic_item.GetListAsync(p=>p.factory_id==10101&&p.org_id==101&&p.tenant_id==101);
  387. //var ic_factory_detailss = _ic_factory_details.GetListAsync(p => p.factory_id == 10101 && p.org_id == 101 && p.tenant_id == 101);
  388. //var ic_item_ies = _ic_item_ie.GetListAsync(p => p.factory_id == 10101 && p.org_id == 101 && p.tenant_id == 101);
  389. //var ic_item_purs = _ic_item_pur.GetListAsync(p => p.factory_id == 10101 && p.org_id == 101 && p.tenant_id == 101);
  390. //var ic_plans = _ic_plan.GetListAsync(p => p.factory_id == 10101 && p.org_id == 101 && p.tenant_id == 101);
  391. //List<ic_item> ic_itemListAdd = new List<ic_item>();
  392. //List<ic_item> ic_itemListUpdate = new List<ic_item>();
  393. //List<ic_factory_details> ic_factory_detailsListAdd = new List<ic_factory_details>();
  394. //List<ic_factory_details> ic_factory_detailsListUpdate = new List<ic_factory_details>();
  395. //List<ic_item_ie> ic_item_ieListAdd = new List<ic_item_ie>();
  396. //List<ic_item_ie> ic_item_ieListUpdate = new List<ic_item_ie>();
  397. //List<ic_item_pur> ic_item_purListAdd = new List<ic_item_pur>();
  398. //List<ic_item_pur> ic_item_purListUpdate = new List<ic_item_pur>();
  399. //List<ic_plan> ic_planListAdd = new List<ic_plan>();
  400. //List<ic_plan> ic_planListUpdate = new List<ic_plan>();
  401. //List<ext_xref> ext_xrefList = new List<ext_xref>();
  402. // if (extMaterials != null)
  403. //{
  404. // extMaterials.Result.ForEach(ext =>
  405. // {
  406. // if(ic_items != null && ic_items.Result.Exists(a=>a.number==ext.FNumber))
  407. // {
  408. // var ic_item = ic_items.Result.FirstOrDefault(a => a.number == ext.FNumber);
  409. // if (ic_item != null)
  410. // {
  411. // ic_item.number = ext.FNumber;
  412. // ic_item.name = ext.FName_2052;
  413. // ic_item.model = ext.FSpecification_2052;
  414. // ic_item.full_name = ext.FDescription_2052;
  415. // ic_item.fms_number = ext.FOldNumber;
  416. // //0.配置类 1. 2.委外加工 3.外购 4.虚拟件
  417. // ic_item.erp_cls = ext.FErpClsID == "配置类" ? 0 : ext.FErpClsID == "自制" ? 1 : ext.FErpClsID == "委外" ? 2 : ext.FErpClsID == "外购" ? 3 : ext.FErpClsID == "虚拟" ? 4 : ext.FErpClsID == "费用" ? 5 : ext.FErpClsID == "服务" ? 6 : -1;
  418. // ic_item.source = ext.FDataSource;
  419. // ic_item.iskeyitem = ext.FIsKitting == "是" ? 1 : 0;
  420. // ic_item.gross_weight = ext.FGROSSWEIGHT;
  421. // ic_item.net_weight = ext.FNETWEIGHT;
  422. // ic_item.maund = ext.FWEIGHTUNITID_Name;
  423. // ic_item.cubic_measure = ext.FVOLUMEUNITID_Name;
  424. // ic_item.length = ext.FLENGTH;
  425. // ic_item.width = ext.FWIDTH;
  426. // ic_item.height = ext.FHEIGHT;
  427. // ic_item.size = ext.FVOLUME;
  428. // ic_item.allowpur = ext.FIsPurchase == "是" ? 1 : 0;
  429. // ic_item.allowsale = ext.FIsSale == "是" ? 1 : 0;
  430. // ic_item.allowmanu = ext.FIsProduce == "是" ? 1 : 0;
  431. // ic_item.allowout = ext.FIsSubContract == "是" ? 1 : 0;
  432. // ic_item.allowbatch = ext.F_SFJLPCH == "是" ? 1 : 0;
  433. // ic_itemListUpdate.Add(ic_item);
  434. // ext_xrefList.Add(new ext_xref
  435. // {
  436. // dop_table_name = "ic_item",
  437. // dop_id= ic_item.Id,
  438. // dop_col1_name= "number",
  439. // dop_col1_value= ic_item.number,
  440. // other_sys_name="kd",
  441. // other_table_name= "in_kd_material",
  442. // other_id=ext.Id,
  443. // other_col1_name= "FNumber",
  444. // other_col1_value=ext.FNumber
  445. // });
  446. // var ic_factory_detail = ic_factory_detailss.Result.FirstOrDefault(a => a.icitem_id == ic_item.Id);
  447. // if (ic_factory_detail != null)
  448. // {
  449. // ic_factory_detail.product_line = ext.F_CPX_Name;
  450. // ic_factory_detail.minpackqty = ext.FIncreaseQty;
  451. // ic_factory_detailsListUpdate.Add(ic_factory_detail);
  452. // }
  453. // var ic_item_ie = ic_item_ies.Result.FirstOrDefault(a => a.icitem_id == ic_item.Id);
  454. // if (ic_item_ie != null)
  455. // {
  456. // ic_item_ie.isbackflush = ext.FIsBatchManage == "是" ? 1 : 0;
  457. // ic_item_ieListUpdate.Add(ic_item_ie);
  458. // }
  459. // var ic_item_pur = ic_item_purs.Result.FirstOrDefault(a => a.icitem_id == ic_item.Id);
  460. // if (ic_item_pur != null)
  461. // {
  462. // ic_item_pur.icitem_name = ic_item.name;
  463. // ic_item_pur.purchgroup = ext.FPurchaseGroupId_Name;
  464. // ic_item_pur.purcher = ext.FPurchaserId_Name;
  465. // ic_item_pur.purchase_unit = ext.FPurchaseUnitId_Name;
  466. // ic_item_purListUpdate.Add(ic_item_pur);
  467. // }
  468. // var ic_plan = ic_plans.Result.FirstOrDefault(a => a.icitem_id == ic_item.Id);
  469. // if (ic_plan != null)
  470. // {
  471. // ic_plan.icitem_name = ic_item.name;
  472. // ic_plan.planner_name = ext.FPurchaseGroupId_Name;
  473. // ic_plan.fix_leadtime = ext.FFixLeadTime;
  474. // ic_plan.plan_trategy = ext.FPlanningStrategy == "MRP" ? 1 : 0;
  475. // ic_plan.order_trategy = ext.FOrderPolicy == "LFL(批对批)" ? 1 : 0;
  476. // ic_plan.order_inter_val = ext.FOrderIntervalTime;
  477. // ic_plan.lead_time = ext.FVarLeadTime;
  478. // ic_plan.bat_change_economy = ext.FVarLeadTimeLotSize;
  479. // ic_plan.order_point = ext.FReOrderGood;
  480. // ic_plan.secinv = ext.FPlanSafeStockQty;
  481. // ic_planListUpdate.Add(ic_plan);
  482. // }
  483. // }
  484. // }
  485. // else
  486. // {
  487. // ic_item item = new ic_item(help.NextId());
  488. // item.number = ext.FNumber;
  489. // item.name = ext.FName_2052;
  490. // item.model = ext.FSpecification_2052;
  491. // item.full_name = ext.FDescription_2052;
  492. // item.fms_number = ext.FOldNumber;
  493. // //0.配置类 1. 2.委外加工 3.外购 4.虚拟件
  494. // item.erp_cls = ext.FErpClsID == "配置类" ? 0 : ext.FErpClsID == "自制" ? 1 : ext.FErpClsID == "委外" ? 2 : ext.FErpClsID == "外购" ? 3 : ext.FErpClsID == "虚拟" ? 4 : ext.FErpClsID == "费用" ? 5: ext.FErpClsID == "服务" ? 6: - 1;
  495. // item.source = ext.FDataSource;
  496. // item.iskeyitem = ext.FIsKitting == "是" ? 1 : 0;
  497. // item.gross_weight = ext.FGROSSWEIGHT;
  498. // item.net_weight = ext.FNETWEIGHT;
  499. // item.maund = ext.FWEIGHTUNITID_Name;
  500. // item.cubic_measure = ext.FVOLUMEUNITID_Name;
  501. // item.length = ext.FLENGTH;
  502. // item.width = ext.FWIDTH;
  503. // item.height = ext.FHEIGHT;
  504. // item.size = ext.FVOLUME;
  505. // item.allowpur = ext.FIsPurchase == "是" ? 1 : 0;
  506. // item.allowsale = ext.FIsSale == "是" ? 1 : 0;
  507. // item.allowmanu = ext.FIsProduce == "是" ? 1 : 0;
  508. // item.allowout = ext.FIsSubContract == "是" ? 1 : 0;
  509. // item.allowbatch = ext.F_SFJLPCH == "是" ? 1 : 0;
  510. // item.tenant_id = 101;//TODO
  511. // item.factory_id = 10101;//TODO
  512. // item.org_id = 101;//TODO
  513. // item.IsDeleted = false;//TODO
  514. // item.is_equipment = 0;
  515. // item.item_level = 0;
  516. // item.hb_level = 0;
  517. // item.matatt = 0;
  518. // item.picktype = 0;
  519. // item.enable_warning = 0;
  520. // ic_itemListAdd.Add(item);
  521. // ext_xrefList.Add(new ext_xref
  522. // {
  523. // dop_table_name = "ic_item",
  524. // dop_id = item.Id,
  525. // dop_col1_name = "number",
  526. // dop_col1_value = item.number,
  527. // other_sys_name = "kd",
  528. // other_table_name = "in_kd_material",
  529. // other_id = ext.Id,
  530. // other_col1_name = "FNumber",
  531. // other_col1_value = ext.FNumber
  532. // });
  533. // ic_factory_detailsListAdd.Add(new ic_factory_details(help.NextId())
  534. // {
  535. // icitem_id = item.Id,
  536. // icitem_name = ext.FName_2052,
  537. // tenant_id = 101,//TODO
  538. // factory_id = 10101,////TODO
  539. // org_id = 101,//TODO
  540. // IsDeleted = false,//TODO
  541. // pick_type= 0,
  542. // stock_time= 0,
  543. // batch_manager=0,
  544. // days_per=0,
  545. // default_chkloc=0,
  546. // default_chksp=0,
  547. // default_loc=0,
  548. // default_sp=0,
  549. // product_line = ext.F_CPX_Name,
  550. // production_leadtime= 0,
  551. // stock_leadtime= 0,
  552. // transportation_leadtime=0,
  553. // order_leadtime = 0,
  554. // minpackqty = ext.FIncreaseQty,
  555. // minorderqty =0
  556. // });
  557. // ic_item_ieListAdd.Add(new ic_item_ie(help.NextId())
  558. // {
  559. // icitem_id = item.Id,
  560. // isbackflush = ext.FIsBatchManage == "是" ? 1 : 0,
  561. // put_integer=0,//TODO
  562. // tenant_id = 101,//TODO
  563. // factory_id = 10101,////TODO
  564. // org_id = 101,//TODO
  565. // IsDeleted = false,//TODO
  566. // });
  567. // ic_item_purListAdd.Add(new ic_item_pur(help.NextId())
  568. // {
  569. // icitem_id = item.Id,
  570. // icitem_name = item.name,
  571. // currency_type= ext.FCurrencyId_Name == "人民币" ? 1 : 0,//TODO
  572. // tenant_id=101,//TODO
  573. // factory_id=10101,////TODO
  574. // org_id =101,//TODO
  575. // IsDeleted =false,//TODO
  576. // supplier_id=0,
  577. // purchgroup = ext.FPurchaseGroupId_Name,
  578. // purcher = ext.FPurchaserId_Name,
  579. // purchase_unit = ext.FPurchaseUnitId_Name
  580. // });
  581. // ic_planListAdd.Add(new ic_plan(help.NextId())
  582. // {
  583. // icitem_id = item.Id,
  584. // icitem_name = item.name,
  585. // planner_name = ext.FPurchaseGroupId_Name,
  586. // fix_leadtime = ext.FFixLeadTime,
  587. // plan_trategy = ext.FPlanningStrategy == "MRP" ? 1 : 0,
  588. // order_trategy = ext.FOrderPolicy == "LFL(批对批)" ? 1 : 0,
  589. // order_inter_val = ext.FOrderIntervalTime,
  590. // lead_time = ext.FVarLeadTime,
  591. // bat_change_economy = ext.FVarLeadTimeLotSize,
  592. // order_point = ext.FReOrderGood,
  593. // secinv = ext.FPlanSafeStockQty,
  594. // tenant_id = 101,//TODO
  595. // factory_id = 10101,////TODO
  596. // org_id = 101,//TODO
  597. // IsDeleted = false,//TODO
  598. // });
  599. // }
  600. // });
  601. // if(ic_itemListAdd.Count>0)
  602. // {
  603. // await _ic_item.InsertManyAsync(ic_itemListAdd);
  604. // }
  605. // if (ic_itemListUpdate.Count > 0)
  606. // {
  607. // await _ic_item.UpdateManyAsync(ic_itemListUpdate);
  608. // }
  609. // if (ic_factory_detailsListAdd.Count > 0)
  610. // {
  611. // await _ic_factory_details.InsertManyAsync(ic_factory_detailsListAdd);
  612. // }
  613. // if (ic_factory_detailsListUpdate.Count > 0)
  614. // {
  615. // await _ic_factory_details.UpdateManyAsync(ic_factory_detailsListUpdate);
  616. // }
  617. // if (ic_item_ieListAdd.Count > 0)
  618. // {
  619. // await _ic_item_ie.InsertManyAsync(ic_item_ieListAdd);
  620. // }
  621. // if (ic_item_ieListUpdate.Count > 0)
  622. // {
  623. // await _ic_item_ie.UpdateManyAsync(ic_item_ieListUpdate);
  624. // }
  625. // if (ic_item_purListAdd.Count > 0)
  626. // {
  627. // await _ic_item_pur.InsertManyAsync(ic_item_purListAdd);
  628. // }
  629. // if (ic_item_purListUpdate.Count > 0)
  630. // {
  631. // await _ic_item_pur.UpdateManyAsync(ic_item_purListUpdate);
  632. // }
  633. // if (ic_planListAdd.Count > 0)
  634. // {
  635. // await _ic_plan.InsertManyAsync(ic_planListAdd);
  636. // }
  637. // if (ic_planListUpdate.Count > 0)
  638. // {
  639. // await _ic_plan.UpdateManyAsync(ic_planListUpdate);
  640. // }
  641. // if (ext_xrefList.Count > 0)
  642. // {
  643. // await _ext_xref.UpdateManyAsync(ext_xrefList);
  644. // }
  645. // }
  646. }
  647. /// <summary>
  648. /// 处理物料清单
  649. /// </summary>
  650. public void DoBom()
  651. {
  652. LogManager.Configuration.Install(new NLog.Config.InstallationContext());
  653. }
  654. }
  655. }